Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!uhog.mit.edu!bloom-beacon.mit.edu!spool.mu.edu!sgiblab!daver!cypress.com!reb
From: reb@cypress.com (Risto Bell /CAD)
Subject: Re: Why is (round 2.5) = 2?
In-Reply-To: britt@tigercat.den.mmc.com's message of Mon, 17 Apr 1995 15:25:40 GMT
Message-ID: <REB.95Apr22192859@de.cypress.com>
Sender: news@cypress.com
Nntp-Posting-Host: delaware.miss.cypress.com
Organization: Cypress Semiconductor Southeast Design Center
References: <jmeehan-1504951641460001@machine.mv.us.adobe.com>
	<1995Apr17.152540.5214@den.mmc.com>
Date: Sun, 23 Apr 1995 00:28:59 GMT
Lines: 51

>>>>> "D" == Dan Britt <britt@tigercat.den.mmc.com> writes:
In article <1995Apr17.152540.5214@den.mmc.com> britt@tigercat.den.mmc.com (Dan Britt) writes:
 D> In article <jmeehan-1504951641460001@machine.mv.us.adobe.com>, jmeehan@mv.us.adobe.com (Jim Meehan) writes:
 D> |> In Common Lisp, round, when applied to a number of the form integer+0.5,
 D> |> returns either integer or integer+1, whichever is even. Does anyone
 D> |> remember why it was defined that way?
 D> |> 
 D> |> For comparison, Scheme does it the same way. fixr in ZetaLisp always
 D> |> rounds up. The Lisp 1.6 manual shows a sample definition that also rounds
 D> |> up. Pascal and PostScript round up.
 D> |> 
 D> |> I didn't see a 'round' operator in my books on Algol, Ada, APL, Basic, C,
 D> |> Fortran, LispVM, MacLisp, ML, or Snobol.
 D> |> 
 D> |> There is one in Smalltalk-80, but from the manual, I couldn't tell what
 D> |> happens in this case.
 D> |> 
 D> |> In Modula-3, the result depends on a thread-specific variable.

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

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

My two cents and apologies if it's redundant, I missed part of the thread.

Your range definitions seem incorrect to me.  [0.0-0.499...]  (square brackets
for inclusive or closed ranges) includes the target of rounding down: 0.0.  If
you want to make this comparison shouldn't the other range be [0.5-1.0]?  Now
it seems clear that 0.5 is by definition precisely in the center and by
arbitrarily including it only in the upper range, that range has a larger
"size."

Technically I think one can prove that .499... == .5 and .99... == 1.0, so may
be the ranges should be described as (0.0-0.5] and [0.5-1.0) (parenthesis for
exclusive or open ranges), again leaving it arbitrary how you treat 0.5.

I was never taught the round-to-even practice, but it sounds like a simple
pseudo-random way of being "fair" and not playing favorites, so that after
many computations perhaps there is less accumulation of error or bias.
--
-Risto    reb@cypress.com     Consortia are formed by losers. --T.J. Rodgers
