[ROOT-8110] TFormula in v6 performs integer division where it used to perform real division in v5 Created: 08/Apr/16  Updated: 18/Apr/16  Resolved: 17/Apr/16

Status: Closed
Project: ROOT
Component/s: Math Libraries
Affects Version/s: 6.06/02
Fix Version/s: None

Type: Bug Priority: High
Reporter: Gianluca Petrillo Assignee: Lorenzo Moneta
Resolution: Won't Fix Votes: 0
Labels: None




ROOT 5's TFormula used to interpret all literal numbers in its expression as double.
The following line evaluated a "1.0/2.0*2.0" and returned "1.0":

root.exe -l <<< 'cout << TFormula("F", "1/2*2").Eval(0.) << endl;'

ROOT 6's TFormula seems to more strictly adhere to a C syntax, and the same line executes "1/2*2" and return "0.0".

This is a serious compatibility break, very easy to be missed.
Can the old behaviour be restored?

Comment by Lorenzo Moneta [ 17/Apr/16 ]


I am sorry, but I prefer to not restore that behaviour. The new TFormula uses Cling as C++ parser so it is correct to get what you would get in written code. I hope this problem can be fixed without too much work by you

Best Regards


Comment by Gianluca Petrillo [ 18/Apr/16 ]

The biggest problem is that we don't even know where TFormula is internally used in ROOT.

I understand you don't want to restore the old behaviour.
Is it possible to mitigate or help the transition?
I am thinking mostly of a special, "transitional" mode in which TFormula throws and exception or prints an error if the expression it's evaluating is not portable. This special mode may be designed not to be meant for regular "production" level (meaning for example it's ok if it takes thrice the CPU time).

Comment by Lorenzo Moneta [ 18/Apr/16 ]


Can you please elaborate more on your usage ? Internally TFormula might be used, but it is the user at the end who inputs the expression, or are you reading functions from a file ?

In this last case one could think of building something to convert the expressions as 1/2 to 1.0/2. But doing this will require lots of work since we are not parsing the operations as before, but we leave this to the compiler.


Generated at Mon Feb 17 07:21:21 CET 2020 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.