Thomas Bähler wrote:
Strange beahviour of the trunc function. This script:
on mouseUp
put 8.1 into Zahl
put Zahl - trunc(Zahl) into Dezimal
put Dezimal*60 & comma & trunc(Dezimal*60)
end mouseUp
should return 6,6
but instead I get 6,5
If I change the first line to
put 8.2 into Zahl
I get 12,11
with
put 8.3 into Zahl
I get 18,18 as expected
RunRev 2.8.1 on Mac OSX 10.4.11
Any explanation?
It works that way because of a widespread acceptance of the failure of
machines to represent numbers logically.
You can work around this using a function that apparently eludes the
authors of most languages:
function logicalTrunc n
if n is not a number then return "NAN"
get offset(".", n)
if it > 0 then
delete char it to -1 of n
end if
return n
end logicalTrunc
--
Richard Gaskin
Managing Editor, revJournal
_______________________________________________________
Rev tips, tutorials and more: http://www.revJournal.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution