----- Original Message ----- 
From: Tab Julius <[EMAIL PROTECTED]>
Subject: <lingo-l> Isn't it about time for a trunc() function?


> I can't believe I never noticed this after all these years (unless I did 
> and forgot it a long time ago - a good possibility), but Lingo has no 
> trunc() function.
> 
> Integer rounds up, so integer(2.58) returns 3.  There's nothing to slice it.
> 
> The age-old workaround to get around this is to add .5 to the source 
> number, and subtract one from the result, as in:
> 
>    truncX =(integer(x + .5)) - 1
> 

If it makes you feel any better, "truncX=bitOr(x,0)" is a little bit faster. 
Furthermore it works with negative integers, which your formula doesn't. Ofcourse it's 
a D8 command and it's not that much faster, really. 13-14% or something.  But I think 
trunc() would probably be just this much faster if it was built in. ;-)
Anyway, whichever you use, just make it a handler and fool yourself into believing 
that the command has been there always. I do that with both trunc and centigrade sine 
operations and many other brilliant commands I used to have in my Amstrad Basic as a 
kid. (Hey, we all have our preferences, don't we?)

/jonas



[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to