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
 








   
_______________________________________________
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

Reply via email to