[BUG] expr doesn't like floats with modulo
Hello.
I just realized that [expr] doesn't deal with float arguments and %.
For example, [expr $f1%1.2] will output the same as [expr $f1%1].
I would call this a bug because [%] deals with float arguments but maybe
it's an expected result ?
Example patch below.
Ciao
The operator % in C only applies to integers, although of course the idea of a "remainder" is apparently simple to apply to floats.
Presumably the % object implements a workaround to simulate a % operation on floats (if it existed in C).
[ expr (($f1 / $f2) - int($f1 / $f2)) * $f2 ]
works in expr, for example.
Beware, though using this expression or the % object due to the floating point representation accuracy:
Output from % object:
1.2 % 1.2 = 0.0
2.4 % 1.2 = 0.0
3.6 % 1.2 = 1.2
4.8 % 1.2 = 0.0
6.0 % 1.2 = 1.2
...
You'd expect the results to be zero.
Thanx for the explanations.
I thought that the same kind of "workaround" was used in [expr] though.
Ciao