I have a strange behaviour of tree… So I have a simple files with 2 columns, like this:
In simple way I read the columns with tree, And then print the values::
tree1= TTree ("tree1","tree1")
while cont < N:
But the output is:
You see that is different respect to the input from the file, from where came the last numbers?? if the number is integer or the decimal is 5 it is ok, but if the values are different I have this a lot digits… why??
Thanks in advance for your help
tree1.ReadFile("myfile.csv", "a/D:b", '\t')
The answer to “why” is: an IEEE 754 floating point variable cannot store 6.8 precisely.
root  cout << setprecision(15) << 6.8f << '\n';
root  cout << setprecision(20) << 6.8 << '\n';
You can store 0.5, 0.25, 0.125, … and multiples losslessly.
For more information, see
https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html if you want to see all details
http://floating-point-gui.de/ if you just want an overview
As you can see in the cout above, Pepe’s solution does not solve your problem, 6.7999999999999998 is just “more equal” to 6.8 than 6.80000019. But then: how precise is the measurement the 6.8 comes from? Is the small uncertainty introduced by the Float_t or Double_t really relevant?
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.