I don't buy "zero doesn't count".  But again, this is getting into serious 
math.  It should be good enough to say 0-4 = 0, 5-9 = 10, but if you don't keep 
strict high precision throughout the whole process and round at every step, 
things are going to be off no matter what.  It's just a matter of being off as 
little as possible (especially when it comes to money.. people are a little 
touchy about that).

Don't malign zero though..  :)

See also:
Zero: The Biography of a Dangerous Idea (Paperback) by Charles Seife

-TG

= = = Original message = = =

I wasn't aware of the accounting trick before today, but I believe I can 
explain it: If your numbers are statistically random, then the above 
solution will lead to an even distribution of rounding up and rounding down.

The reason is simple:
0: No rounding. It's already there. (8.0 doesn't need to be rounded to 8 
- it already *is* 8.)
1-4: You round down -> 4 of 9 times you round down.
5-9: You round up -> 5 of 9 times you round up.

So you round up 11.1% more often than you round down. As a result, if 
you round up when it's odd, and down when it's even, you eliminate the 
11.1% difference in when you'd round up then round down.

That said, if someone were aware of the above rounding trick, it 
wouldn't take someone very much effort to come up with things like "fee 
structures" or "pricing structures" that could take advantage of that 
scheme to force rounding errors to remain permanently in the person's favor.

I certainly hope that PHP continues to use the standard technique, and 
not the "accounting trick" above. :-)

jon


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to