Re: How can I round in applescript to 3 digits after a period?
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: Rob Stott <email@hidden>
- Date: Thu, 3 Jan 2008 11:28:36 +0000
On 3 Jan 2008, at 10:34, Patrik B. wrote: 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
I'd do it something like this...
set theRoundedNumber to roundTheNumber(19.989892397892, 3)
on roundTheNumber(theIntegerToRound, theDecimalPlaces) set theMultiplier to (10 ^ theDecimalPlaces) set theNumber to theIntegerToRound * theMultiplier set theNumber to round theNumber rounding up set theNumber to theNumber / theMultiplier end roundTheNumber
...the first parameter is the number to be rounded. The second parameter is the number of decimal places.
Hope that's some help
Rob
Important: This message is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination or copying of the communication is strictly prohibited. If you have received this communication in error, please notify the writer immediately by telephone and return the original message via postal service to the writer's attention at the above address. Thank you.
Watt Gilchrist Limited. Albion Mills, Albion Road. Bradford, BD10 9TQ
Registered in England
873405
|
_______________________________________________
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