[R] problem with sum function
wdunlap at tibco.com
Thu Mar 1 23:01:37 CET 2012
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.
Spotfire, TIBCO Software
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Mark A. Albins
> Sent: Thursday, March 01, 2012 1:50 PM
> To: r-help at r-project.org
> Subject: [R] problem with sum function
> 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:
> Why doesn't R return zero in this case? There shouldn't be any rounding
> error in a simple sum.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help