Kay C Lan lan.kc.macmail at
Tue Feb 12 05:01:15 EST 2008

On Feb 11, 2008 7:11 PM, Eric Chatonet <eric.chatonet at>

> function logicalTrunc n
>   if n is not a number then return "NAN"
>   return n - (n mod 1)
> end logicalTrunc

I don't fully understand Richard's explanation of why machines fail to
represent numbers but I extrapolated that to mean that if trunc doesn't work
then mod would suffer the same failure:

I therefore rewrote Thomas function to include your n  - (n mod 1)
alternative, it looks like this:

put 8.3 into Zahl
put Zahl - (Zahl - (Zahl mod 1)) into Dezimal
put Dezimal*60 & comma & (Dezimal*60 - ((Dezimal *60) mod 1))

Placing the above in the Msg Box and using Thomas' same three examples of
8.1, 8.2 and 8.3, the answers are exactly the same as for trunc, 6,5  12,11
& 18,18.

So I think if Thomas wants to get the answer he's expecting he should avoid
both trunc and mod.


More information about the Use-livecode mailing list