• 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: How can I round in applescript to 3 digits after a period?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I round in applescript to 3 digits after a period?


  • Subject: Re: How can I round in applescript to 3 digits after a period?
  • From: Axel Luttgens <email@hidden>
  • Date: Thu, 03 Jan 2008 12:21:49 +0100

On 3/01/08 11:34, Patrik B. wrote:

Hi,

This might sound silly but how do you round a real number in applescript to 3
digits after the period?


I.e. 19.9898923978923892 should just be rounded to 19.989
Also 19.0909 should just be rounded to 19.989


Must be a typo here... ;-)
Did you mean 19.09?

Per what I understand rounding in applescript rounds to an integer so is there
a different rounding method that I can use to round to three digits after the
period?

A quick way, assuming you are interested in numerical values, not in their string representation:


   set R to 19.989892397892
   (round (R * 1000) rounding down) / 1000

Of course this might need some adjustments, depending on your needs (e.g. handling negative numbers, or large ones).


HTH, Axel _______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >How can I round in applescript to 3 digits after a period? (From: "Patrik B." <email@hidden>)

  • Prev by Date: Re: Dates
  • Next by Date: Re: How can I round in applescript to 3 digits after a period?
  • Previous by thread: How can I round in applescript to 3 digits after a period?
  • Next by thread: Re: How can I round in applescript to 3 digits after a period?
  • Index(es):
    • Date
    • Thread