Re: rounding integers
Re: rounding integers
- Subject: Re: rounding integers
- From: Pat Cannon <email@hidden>
- Date: Fri, 31 Oct 2003 10:55:18 -0600
Would someone be able to get me started on how to round a number to
two decimals?
The trick (you would have thought of this in a while) is to multiply
by 100, then round the result, then divide the resulting integer by
100.
on roundToCents(x)
return (round (100 * x) rounding as taught in school) / 100
end roundToCents
roundToCents(2.66666666)
--2.67
You may want to add some code to manipulate the number as text to add
a final zero when you get a result of say, 1.5.
Pat
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.