How read a filenode with value like 7.6750000000000005e-001 ? [closed]

asked 2014-08-20 08:40:33 -0600

tuco gravatar image

I'm reading values from a xml file and sometimes I'd a value like 7.6750000000000005e-001 but the FileNode::isReal is not getting it right and when I put (float) file[i] it's getting 0, how do I do to get the right value and why the isReal isn't working properly ?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by StevenPuttemans
close date 2014-08-22 11:13:14.105776

Comments

This tutorial reads in exponentially stored values from a XML/YML file. Could you please check if you are using the same approach? Probably something is wrong in grabbing the data.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-20 08:52:59 -0600 )edit

well, in this tutorial it shows using integer, I do like I said, float var = (float) file["tag"], and this doesn't work.

tuco gravatar imagetuco ( 2014-08-20 10:52:41 -0600 )edit
1

Hmmm looking at

 <MyData>
   <A>97</A>
   <X>3.1415926535897931e+000</X>
   <id>mydata1234</id></MyData>
 </opencv_storage>

I got the idea that the X under mydata is a double. Under point 5 in the explanation it is illustrated how to retrieve using

 X = (double)node["X"];

I am guessing that the exponential number can only be read as doubles, not as float type.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-22 04:18:15 -0600 )edit

And the crap system destroyed the code sample, but take a closer look at the tutorial and you see what I mean.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-22 04:40:57 -0600 )edit

this make sense but it's returning 0.00000000000000000 now ...

tuco gravatar imagetuco ( 2014-08-22 08:49:28 -0600 )edit

Could you please add your complete code here ... its pure guessing work now!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-22 08:51:19 -0600 )edit
1

wow, sorry ... it's working

tuco gravatar imagetuco ( 2014-08-22 08:57:18 -0600 )edit