Re: rounding to decimal place
Re: rounding to decimal place
- Subject: Re: rounding to decimal place
- From: Doug McNutt <email@hidden>
- Date: Sun, 9 Oct 2005 12:50:20 -0600
At 08:33 +0200 10/9/05, Wayne Melrose wrote:
>what is the best way to round numbers to the nearest decimal place?
>
>1.123945565
>to
>1.124
The classic procedure is:
1) multiply by 1000
2) add 0.5
3) truncate to an integer
4) divide by 1000
But step 4 may introduce an "error" because 1/1000 is not exactly expressible as a floating point binary number. Figuring out how to tell AppleScript to print in a three decimal digit format is beyond my mental capacity. Perhaps inserting the decimal point into the character string that represents the integer at step 3.
--
--> On the eighth day, about 6 kiloyears ago, the Lord realized that free will would make man ask what existed before the Creation. So He installed a few gigayears of history complete with a big bang and a fossilized record of evolution. <--
_______________________________________________
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