Hi Hugh,
You are right :-)
Not correct with calculations...
Le 12 févr. 08 à 08:20, [EMAIL PROTECTED] a écrit :
Eric wrote:
function logicalTrunc n
if n is not a number then return "NAN"
return n - (n mod 1)
end logicalTrunc
Sorry, Eric... MOD suffers from the same same floating point issue
as TRUNC:
get (36 - 34.1) * 100 --> 190, good
put it - (it MOD 1) --> 189, bad
Avoiding them obtains the expected answer:
get logicalTrunc ((36 - 34.1) * 100) --> 190, good
function logicalTrunc n
if n is not a number then return "NAN"
set the itemDel to "."
return item 1 of n
end logicalTrunc # by Kay C Lan
or
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 # by Richard Gaskin
Bottom line:
Use TRUNC and MOD with single numbers, not with calculations
/H
Best regards from Paris,
Eric Chatonet.
----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: [EMAIL PROTECTED]/
----------------------------------------------------------------
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution