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

Marc R. Feldesman feldesmanm at pdx.edu
Sat Mar 15 23:49:05 CET 2003


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



More information about the R-help mailing list