...and I was wondering why things didn't work..
Just try
[expr 1/3], or
[expr 1/3*$f1], or
[expr if($f1<1000, 1/3*$f1, 5)]
and look at the output...
It seems the "1/3" (and other fractions) are rounded to the next lower integer.
It's strange but [expr $f1*1/3] works (as well as [expr 1*3*$f1] & [expr 1/(3/$f1)]).
Can anyone confirm this??
Bye
-
Argh! \[Expr\] bug ?!
-
The division is not evaluated as float when it gets evaluated first. So 1./3 instead of 1/3 should be used in this case.
-
Yeah, [expr] is based on C expressions, and you have to be explicit sometimes with the data types. In C, if it looks like an integer in the expression, it will evaluate to an integer output. And it's also based on the precedence order of operations, so even if you have a float outside of parentheses, for example, if what's in the parentheses are all integers, the expression in the parentheses will be evaluated to an integer. So you just have to watch out. The safest thing to do is to do what ktsouk said and just stick a decimal point in there, just in case. That forces it to be considered a float.
-
Thx!
A little confusing if you never did C... Is there a reason for this?