Re: “round” command rounding algorithms
Re: “round” command rounding algorithms
- Subject: Re: “round” command rounding algorithms
- From: Chris Page <email@hidden>
- Date: Thu, 04 Jun 2009 21:09:43 -0700
On Jun 4, 2009, at 4:31 PM, Doug McNutt wrote:
And my biggest problem is Apple's "rounding as taught in school". I was never taught anything like that and I really would like to know Apple's rules for remainders that are exactly 1/2 of a digit or for negative values.
If that’s your biggest problem, you’re doing fantastically. ;-)
(I was taught, in school, that -2^2 was a negative number but that's another question.) See my other reply, about Minus-Hypen, et al.
Wikipedia has a good article on rounding and various algorithms:
The “round” command has a “rounding” parameter that lets you control which algorithm is used. The “as taught in school” algorithm is the one I was taught in elementary school.
rounding roundingDirectionThe direction to round. You may specify one of the following rounding directions: up Rounds to the next largest integer. This is the same as the math “ceiling” function. down Rounds down to the next smallest integer. This is the same as the math “floor” function. toward zero Rounds toward zero, discarding any fractional part. Also known as truncation. to nearest Rounds to the nearest integer; .5 cases are rounded to the nearest even integer. For example, 1.5 rounds to 2, 0.5 rounds to 0. Also known as “unbiased rounding” or “bankers’ rounding.” See Discussion for details. as taught in school Rounds to the nearest integer; .5 cases are rounded away from zero. This matches the rules commonly taught in elementary mathematics classes.
- Default Value:
to nearest
-- Chris Page
The other, other AppleScript Chris
|
_______________________________________________
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