Hello,
I have a peculiar situation; When I use Draw selection option with a branch of “int” type, int count = Tree->Draw(“y:x2”, “x1==int”, “goff”); its works;
When I take a float (decimal) value branch, for instance
int count = Tree->Draw(“y:x2”, “x3==0.08”, “goff”);
no entries (incorrect of course); Any ideas,
thanks, Damir
ROOT Version: 6
Platform: Linux
Compiler: gcc 6.3.0
So you don’t get any output either if you do this?
Tree->Scan("y:x2","x3==0.08");
If not, can you post the output of Tree->Print() ? To get nice formatting like my line above, when you paste here enclose the output lines within three single left quote marks (```), see here.
I assume it’s:
(double(0.08)) - (float(0.08))
Try:
Long64_t count = Tree->Draw("y:x2", "abs(x3 - 0.08) < (0.08 * 1.e-5)", "goff"); // 1.e-5 = "5 significant decimal digits precision"
works! very nice; Different topic why this sensitivity to float, because when I do Scan I do see 0.08 going to 0.07999 which was the cause of the issue,
cheers, Damir
If you want “0.07999” to be included, you should use something like (0.08 * 2.e-4), which means slightly less than 4 significant decimal digits precision (actually, something like 1.26e-4 instead of 2.e-4 could be sufficient).
See also:
cppreference.com -> C++ -> C++ language -> Basic Concepts -> Fundamental types
Wikipedia - Floating point
“Floating point - Representable numbers, conversion and rounding”
C/C++ “double” usually means: Double-precision floating-point format
C/C++ “float” usually means: Single-precision floating-point format