• 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 a number towards zero!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Round a number towards zero!


  • Subject: Re: Round a number towards zero!
  • From: has <email@hidden>
  • Date: Fri, 18 Mar 2005 17:42:46 +0000

Christian Vinaa wrote:

how do I then fx round to x decimals ?

AppleMods' Number library <http://applemods.sourceforge.net/mods/Data/Number.php > provides a collection of rounding and trimming commands, e.g.:


-- (library loading code omitted for clarity)

_Number's trimTowardZero(1000.1234, 2)
--> 1000.12

BTW, this library incorporates a fix for rounding errors in AppleScript discovered by Emmanuel Levy, so should give more reliable results than a naive solution.

If you've not used AppleMods' libraries before, you'll need to download and install AppleMods' Loader system first <http://applemods.sourceforge.net/getstarted.html>. Run the Loader installer, then download and add the Number library to the ASLibraries folder. You can use the LoaderWizard applet to generate the library loading code to paste at the top of your script.

HTH

has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: iCal organization with dates & events & lists....
  • Next by Date: Re: Round a number towards zero!
  • Previous by thread: Re: Round a number towards zero!
  • Next by thread: Re: Round a number towards zero!
  • Index(es):
    • Date
    • Thread