Re: Floor & Ceiling (no walls yet)
Re: Floor & Ceiling (no walls yet)
- Subject: Re: Floor & Ceiling (no walls yet)
- From: Richard Morton <email@hidden>
- Date: Tue, 3 Feb 2004 21:03:56 +1100
On 03/02/2004, at 10:10 AM, ehsan saffari wrote:
Here is my attempt at defining Floor & Ceiling functions in
AppleScript:
Anything wrong there? Can they be improved?
I think the great NG has some superfast handlers for these functions -
search for 'rounderRound' on Macscripter - but this deals with zero &
the integral values I tested it with:
on getCeiling(n)
if (n mod 1) is not 0 then if n > 0 then
return (n div 1) + 1
else
return n div 1
end if
return n
end getCeiling
The 1st test -- (n mod 1) is not 0 -- weeds out the numbers we don't
want to process, so it just goes straight to the last return statement
on those.
----Get Ceiling of a number----
on getceil(x)
if x > 0 then
set y to (x div 1) + 1
else if x < 0 then
set y to (x div 1)
end if
return y
end getceil
----
----Get Floor of a number----
[...]
This could be modified in the same manner.
Thanks for any comments
Cheers,
Floyd T Ceiling-Windows
-- there is water at the bottom of the ocean
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.