Subject: Re: Why is (round 2.5) = 2? From: Erik Naggum <erik@naggum.no> Date: 1995/04/16 Newsgroups: comp.lang.lisp Message-ID: <19950416T033512Z.enag@naggum.no> [Jim Meehan] | In Common Lisp, round, when applied to a number of the form | integer+0.5, returns either integer or integer+1, whichever is even. | Does anyone remember why it was defined that way? I don't "remember", but when I asked the same question not long ago, I was told that it was mathematically correct, which indeed it is. (loop for x from 0 to 99 sum (+ 1/2 x)) => 5000 (loop for x from 0 to 99 sum (round (+ 1/2 x))) => 5000 if round "rounded up", you would get (loop for x from 0 to 99 sum (ceiling (+ 1/2 x))) => 5050 that is, for a random distribution of numbers, adding values after rounding will yield Pentium-size errors if (round x) == (floor (+ 1/2 x)). #<Erik> -- sufficiently advanced political correctness is indistinguishable from irony