Strange math behaviour... could someone explain this ?

Mark Wieder mwieder at ahsoftware.net
Sun Oct 9 14:05:52 EDT 2005


Mark-

Sunday, October 9, 2005, 4:58:45 AM, you wrote:

> The solution to the issue you have here is to always add a small
> 'epsilon' value to your numbers before truncating.

Sorry, Mark, but that won't do it.

on mouseUp
  local tValue
  
  put 179.99999999999971578291 into tValue
  put trunc(tValue + 1e-8)
end mouseUp

In this case you get 180, even though the specified value is less than
180 by a finite amount, which has the effect of rounding the value to
the next higher integer instead of truncating it.

-- 
-Mark Wieder
 mwieder at ahsoftware.net




More information about the use-livecode mailing list