Others explained why it happens, but you might want to look at the zapsmall function for one way to deal with it.
On Thu, Mar 1, 2012 at 2:49 PM, Mark A. Albins <kamoko...@gmail.com> wrote: > 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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com ______________________________________________ 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.