Forum OpenACS Q&A: Re: Tcl weird behaviour with math

Posted by Antonio Pisano on
Thanks for your fast and clear explanation Benjamin, I will update my procs so they truncate all digits beyond required precision before being ceiled and this should do the trick.

All the best


Posted by Gustaf Neumann on
The best is to calculate internally the only the smallest unit (i.e. cents) in integers, calculate with these, and format these as required to dollar, euro, etc.

In the more general case, you might want to look into the tcl decimal arithmetic package:

In some simple cases, it might be sufficient to work with a comparison operator with an espilon fuzz value (e.g. withinEpsilon is

best regards
-gustaf neumann