[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
Environment:

Linux


Development:

 Description   

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?



 Comments   
Comment by Lorenzo Moneta [ 17/Apr/16 ]

Hi,

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

Lorenzo

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 ]

Hi,

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.

Lorenzo

Generated at Wed Sep 18 15:22:15 CEST 2019 using Jira 7.13.1#713001-sha1:5e06076c2d215a6f699b7e5c90ab2fae7ba5a1ce.