Re: Rounding
Re: Rounding
- Subject: Re: Rounding
- From: Arthur J Knapp <email@hidden>
- Date: Wed, 20 Mar 2002 16:40:03 -0500
>
Subject: Re: Rounding
>
Date: Wed, 20 Mar 2002 09:49:24 +0000
>
From: Nigel Garvey <email@hidden>
>
Rob Jorgensen wrote on Tue, 19 Mar 2002 20:47:10 -0500:
>
> So, how do I round 14 to 15, or 16 to 20? Does anyone care to share a
>
> handler which addresses this?
>
As long as you're only dealing with positive whole numbers, this should
>
be enough:
>
>
on rndUpTo5(n)
>
(n + 4) div 5 * 5
But Nigel...
What if the universe were to stop expanding and to begin its slow
return to the big bang. In that case, is it not possible that time
itself might start to move backwards, thereby breaking any script
that assumes that seconds will always be positive whole numbers ???
(where is my medication?) ;-)
Am I correct in assuming that your handler can be generalized as this: ?
on rndUpToX(n, x)
return (n + (x - 1)) div x * x
Good stuff. :)
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://maccentral.macworld.com/columns/briggs.shtml>
on error number -128
end try
}
_______________________________________________
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.