Re: Rounding
Re: Rounding
- Subject: Re: Rounding
- From: Nigel Garvey <email@hidden>
- Date: Wed, 20 Mar 2002 09:49:24 +0000
Rob Jorgensen wrote on Tue, 19 Mar 2002 20:47:10 -0500:
>
Howdy,
>
>
I need to extract the minutes from the time string of current date
>
and then round them up to the next 5 minute increment. I can extract
>
the minutes with no problem but the rounding is my weak spot (my loss
>
of mathematical ability is documented in the archives of this list).
>
:P
>
>
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
end rndUpTo5
The minutes of the time are of course rounded *down* from the combined
figure for minutes and seconds, so rounding them up to the nearest five
minutes would only occur after the completion of the first minute of each
five.
NG
_______________________________________________
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.