[R] round() seems inconsistent when rounding 5s

Warnes, Gregory R gregory_r_warnes at groton.pfizer.com
Sun Mar 16 00:14:54 CET 2003


Actually, under the default IEEE rounding mode, decimal values ending in 5
are always rounded to the nearest even value.   This intended to ensure that
rounding does not systematically bias computations in one direction, as
would happen if 5's were always rounded either up or down.

A very useful review of the issues in floating point computations on
computer and under IEEE standard arithmetic is the paper "What Every
Computer Scientist Should Know About Floating-Point Arithmetic", by David
Goldberg, published in the March, 1991 issue of Computing Surveys.  This
paper is reprinted on the Sun website at
http://docs.sun.com/source/806-3568/ncg_goldberg.html.

-Greg

> -----Original Message-----
> From: Marc R. Feldesman [mailto:feldesmanm at pdx.edu]
> Sent: Saturday, March 15, 2003 5:49 PM
> To: Rashid Nassar; r-help
> Subject: Re: [R] round() seems inconsistent when rounding 5s
> 
> 
> At 01:53 PM 3/15/2003, Rashid Nassar wrote:
>  >It may be my lack of unerstanding, but round() seems to me to give
>  >inconsistent results when rounding 5s as in the following examples?
> 
> Not really.  Floating point numbers can't be precisely represented in 
> binary and so the internal representation of 1.5 might be 
> very different 
> from what you think it is.  If you've done any programming at 
> all, this is 
> one of the first lessons you learn about "real" numbers and computers.
> 
> 
> Dr. Marc R. Feldesman
> Professor and Chairman Emeritus
> Anthropology Department - Portland State University
> email:  feldesmanm at pdx.edu
> email:  feldesman at attglobal.net
> fax:    503-725-3905
> 
> 
> "Sometimes the lights are all shining on me, other times I 
> can barely see,
> lately it's occurred to me, what a long strange trip it's 
> been..."  Jerry &
> the boys
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


LEGAL NOTICE\ Unless expressly stated otherwise, this message is... [[dropped]]



More information about the R-help mailing list