From ... From: Erik Naggum Subject: Re: Why is (round 2.5) = 2? Date: 1995/04/22 Message-ID: <19950422T110155Z.enag@naggum.no>#1/1 X-Deja-AN: 101233895 references: <1995Apr17.152540.5214@den.mmc.com> <1995Apr19.183312.17989@den.mmc.com> organization: Naggum Software; +47 2295 0313 newsgroups: comp.lang.lisp [Dan Britt] | Except that in the range 0 | 1 ... 9 | 10, zero equals ten (with | respect to rounding). And, the real number line _does_ include | integers, so the range is 0 (exactly, not 0.00...01) through | 0.49999.... There are exactly as many real numbers between 0 and | 0.49999... inclusive as there are between 0.5 and 0.99999... inclusive, | so the habit of rounding .5 down half of the time means rounding down | more often than rounding up. Finite precision arithmetic may either | mitigate or exacerbate that; I don't know. But this subject has to do | with open vs closed intervals on the real number line. The interval [0, | .5) is the same size as the interval [.5, 1) (though it's been so long | I might have the symbols reversed), and that [.5 means include .5, | whereas .5) means don't include it. I don't know whether this is a useful way to see it, but it does show that round-up is a better solution under the stated premises. the question is whether those premises are optimal. I don't think so. instead of looking at the size of the ranges [0,.5) and [.5,1), we should look at the range of numbers that round to a given integer. e.g., the numbers that round to zero are in the range [-.5,+.5). this range is slightly off balance, and it is this imbalance that accumulates errors. in a round-to-even scheme, the numbers that round to an even integer n are in the range [n-.5,n+.5], which balances perfectly. the numbers that round to an odd integer n is in the range (n-.5,n+.5), which also balances. this balance yields correct results. # -- sufficiently advanced political correctness is indistinguishable from irony