• 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: "Arthur J Knapp" <email@hidden>
  • Date: Wed, 06 Dec 2000 16:49:57 -0500

> From: "Bourque, Jason" <email@hidden>
> Subject: Round Handler, care to share.
> Date: Wed, 6 Dec 2000 15:35:23 -0500

> 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

??? What is your criterion for rounding, multiples of 5 ???

And if so, why does 22.8 round to 25 ? It is "closer" to 20.

Oh, perhaps you want to round up to the next multiple of 5?

on NextMultiple( num, multi )

set increment to multi
repeat until num < multi
set multi to multi + increment
end repeat

return multi

end NextMultiple

NextMultiple(17.2, 5)
--> 20

NextMultiple(22.8, 5)
--> 25


--
{
Arthur J Knapp, of STELLARViSIONs ;

http://www.STELLARViSIONs.com ;

mailto:email@hidden ;

http://developer.apple.com/techpubs/
macos8/InterproCom/AppleScriptScripters/
AppleScriptLangGuide/
}


  • Prev by Date: Re: Round Handler, care to share.
  • Next by Date: Re: Idle Help
  • Previous by thread: Re: Round Handler, care to share.
  • Next by thread: Re: Round Handler, care to share.
  • Index(es):
    • Date
    • Thread