• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Round Handler, care to share.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Round Handler, care to share.


  • Subject: Re: Round Handler, care to share.
  • From: Nigel Garvey <email@hidden>
  • Date: Thu, 7 Dec 2000 00:07:21 +0000

"Bourque, Jason" wrote on Wed, 6 Dec 2000 15:35:23 -0500:

>Hello,
>
>Does anyone have a vanilla handler that finds the next rounded value of a
>number, this is to be used in charts.
>
>i.e. 17.2 rounded would be 20
>
>22.8 rounded would be 25

It looks as though you want to round *away from zero* to the next
multiple of 5. If so, this is very fast:

on rndAwayTo5(n) -- away from zero
tell n div 5 * 5
if it < n then return it + 5
if it > n then return it - 5
it
end tell
end rndAwayTo5

If, on the other hand, you want the *nearest* multiple of 5 (2.5 rounding
away from zero):

on rndTo5(n) -- to nearest 5
tell n / 5
(it div 0.5 - it div 1) * 5
end tell
end rndTo5

NG


  • Prev by Date: Re: emailer script question....
  • Next by Date: looking for scriptable graphics app.
  • Previous by thread: Re: Round Handler, care to share.
  • Next by thread: Re: Round Handler, care to share.
  • Index(es):
    • Date
    • Thread