Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!howland.reston.ans.net!agate!boulder!news.coop.net!news.den.mmc.com!britt
From: britt@tigercat.den.mmc.com (Dan Britt)
Subject: Re: Why is (round 2.5) = 2?
Message-ID: <1995Apr17.152540.5214@den.mmc.com>
Sender: britt@tigercat (Dan Britt)
Nntp-Posting-Host: tigercat.den.mmc.com
Organization: Martin Marietta Astronautics Group
References:  <jmeehan-1504951641460001@machine.mv.us.adobe.com>
Date: Mon, 17 Apr 1995 15:25:40 GMT
Lines: 30

In article <jmeehan-1504951641460001@machine.mv.us.adobe.com>, jmeehan@mv.us.adobe.com (Jim Meehan) writes:
|> 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?
|> 
|> For comparison, Scheme does it the same way. fixr in ZetaLisp always
|> rounds up. The Lisp 1.6 manual shows a sample definition that also rounds
|> up. Pascal and PostScript round up.
|> 
|> I didn't see a 'round' operator in my books on Algol, Ada, APL, Basic, C,
|> Fortran, LispVM, MacLisp, ML, or Snobol.
|> 
|> There is one in Smalltalk-80, but from the manual, I couldn't tell what
|> happens in this case.
|> 
|> In Modula-3, the result depends on a thread-specific variable.

I've seen this thread before and don't remember the answer (maybe it's
ease of implementation).  It seems to me that mathematically (using
infinite precision arithmetic) rounding toward an even number is wrong.
The "size" of the real number space including 0.0 through 0.49999... is
equal to that including 0.50 through 0.99999....  Thus, one should always
round anything at or above .5 up.  But that's with infinite precision.
Digital representations may change things...

Dan
______________________________________________________________________
Daniel L. Britt				Martin Marietta Astronautics
britt@tigercat.den.mmc.com		Opinions expressed are my own,
303-977-1682				not those of my employer.
