Many thanks to all for the very quick replies. I should have stated the apparent problem more clearly: round() does not seem to always round 5 to the nearest even value as I expected, as my examples (repeated below) showed:
> round(2.45, 1) [1] 2.5 # shouldn't this be 2.4? > round(1.05, 1) [1] 1.1 # 1.0 ? > signif(3.445, 3) [1] 3.45 # 3.44 ? Apologies for not stating this more clearly in my first message, and again thanks for the replies. Rashid Nassar On Sat, 15 Mar 2003, Warnes, Gregory R wrote: > 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:[EMAIL PROTECTED] > > 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: [EMAIL PROTECTED] > > email: [EMAIL PROTECTED] > > 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 > > > > ______________________________________________ > > [EMAIL PROTECTED] mailing list > > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > > > > LEGAL NOTICE > Unless expressly stated otherwise, this message is confidential and may be > privileged. It is intended for the addressee(s) only. Access to this E-mail by > anyone else is unauthorized. If you are not an addressee, any disclosure or copying > of the contents of this E-mail or any action taken (or not taken) in reliance on it > is unauthorized and may be unlawful. If you are not an addressee, please inform the > sender immediately. > ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
