Root does not see bugs

Hello,

I have a problem with ROOT. It doesn’t always see typos and missing “;”.

Moreover I have two tables and I compare their values. I obtain different results when I do operation like:

	 Weight_z[i]=(-40.+i)/10.;

and
Weight_z[i]=(-40.+i)*0.1;

Could you please advise me what I shall do?

Best regards,
Agnieszka

You could (and should) always check your macros with a proper compiler, e.g. by compiling them from the interpreter.

[0] .L macro.C+

You expect you should get the same answer because you assume that 1./10=0.1. This is not true for double types (that’s the type of 10. and 0.1). While 10.0 can be exactly represented as a double, 0.1 cannot (try in the interpreter). That’s why in the second form you incur rounding errors (in the ROOT interpreter like in any C or C++ code).

[quote]I have a problem with ROOT. It doesn’t always see typos and missing “;”.[/quote] How do you expect ROOT to KNOW that something YOU wrote is a “typo” or that YOU forgot to put a “;” somewhere there?
The interpreter is expected to execute the source code EXACTLY as YOU wrote it.

BTW. I see no problem with “rounding errors” here …
root [0] (1 / 10.0) - 0.1
(const double)0.00000000000000000e+00
root [1] (1.0 / 10) - 0.1
(const double)0.00000000000000000e+00
root [2] 0.1 * 10.0
(const double)1.00000000000000000e+00