In base ten, using any fixed number of digits, compute 1/3 + 1/3 + 1/3 (doing the divisions before the additions). Why isn't it 1?
1/5 has the same sort of problem in base two. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Mark A. Albins > Sent: Thursday, March 01, 2012 1:50 PM > To: r-help@r-project.org > Subject: [R] problem with sum function > > Hi! > > I'm running R version 2.13.0 (2011-04-13) > Platform: i386-pc-mingw32/i386 (32-bit) > > When i type in the command: > > sum(c(-0.2, 0.8, 0.8, -3.2, 1.8)) > > R returns the value: > > -5.551115e-17 > > Why doesn't R return zero in this case? There shouldn't be any rounding > error in a simple sum. > > Thanks, > > Mark > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.