Re: number with one decimal
Re: number with one decimal
- Subject: Re: number with one decimal
- From: Steve Thompson <email@hidden>
- Date: Tue, 19 Jul 2011 00:28:06 +0100
On 18 Jul 2011, at 23:16, Mark J. Reed wrote: Any computer software using floating-point arithmetic shares AppleScript's opinion on that.
Not true. Some software handles it better than others. This is a rounding problem, but if all you care about is the output, just fake the division when you do the string conversion yourself. Assuming scale is an integer:
Scale is always an integer. You can't have 3 and a half decimal places
(text 1 through -2 of (scale as text)) & "." & (text end of (scale as text)) That moves the decimal point if you're dividing by 10. It doesn't work for any other divisor or any values between -9 and 9. However, rounding errors in AS exists for all divisors and dividends.
I think you misread my code - open up Terminal and type
echo "scale=12;1/98" | bc
You'll get the answer
bc has no problems with rounding so if I encounter this problem I pass all my calculations off to bc instead of letting AS deal with it.
Steve
___________________________________________________
|
_______________________________________________
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