Re: Rounding
Re: Rounding
- Subject: Re: Rounding
- From: Malcolm Fitzgerald <email@hidden>
- Date: Wed, 20 Mar 2002 14:36:24 +1100
This one rounds up and down
to round_about(i, r)
set j to i mod r
if j (r / 2) then ,
set j to j - r
return i - j
end round_about
round_about(127.4, 5) -- 125
round_about(6, 5) -- 5
round_about(13, 7) --> 14
This one rounds up
to round_up(i, r)
return i + r - ( i mod r)
end round_up
round_up(127.4, 5) -- 130
round_up(6, 5) -- 10
round_up(13, 7) --> 14
At 8:47 PM -0500 19/3/02, Rob Jorgensen wrote:
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?
--
Malcolm Fitzgerald
Database Manager
The Australian Society of Authors
ph: 02 9318 0877 fax: 02 9318 0530 email: email@hidden
www.asauthors.org www.asauthors.org/award www.asauthors.org/web_of_poets
_______________________________________________
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.
References: | |
| >Rounding (From: Rob Jorgensen <email@hidden>) |