Re: magic integer converter number 62?
Re: magic integer converter number 62?
- Subject: Re: magic integer converter number 62?
- From: Nigel Garvey <email@hidden>
- Date: Thu, 22 Feb 2001 15:09:46 +0000
Nigel Smith wrote on Thu, 22 Feb 2001 10:39:08 +0000:
>
NG suggested using
>
>
num div 1
>
>
in response to MShaw's need to recreate(?)
>
>
on floor(num)
>
return (((100 + (num - (num mod 1))) - 100) as integer)
>
end int
>
>
>
I may be wrong, I'm no programmer, but isn't floor *always* rounding down?
I'd never heard the term before, so I just offered something that did the
same as the handler, which rounds towards zero. What you say sounds
likely though, so I apologise if my suggestion wasn't right for the job.
>
on floor(num)
>
if num < 0 then
>
return (num div 1) - 1
>
else
>
return num div 1
>
end if
>
end floor
>
>
...should do the business (though someone is bound to point out a quicker
>
way!).
I devoted some time last year to writing my own fast rounding handlers,
and your effort consistently beats my rounding-down handler (today, at
least) by a few ticks over a few thousand iterations on my 4400.
NG