samaya6501 at yahoo.com.tw
2008-Aug-08 11:30 UTC
[Rd] Truncation error on simply mean & sum function (PR#12515)
Full_Name: Tom Wang Version: 2.6.2 OS: Linux, Windows Submission from: (NULL) (61.230.6.228) I've found an instance:> a <- c(0.187,-0.019,0.074,-0.06,0.221,-0.079,0.12,0.079,-0.281,-0.242) > sum(a)[1] -2.428613e-17 The actual sum is 0 but it reports the wrong answer. Maybe it is due to the computer truncation error.
Christian Brechbühler
2008-Aug-08 13:26 UTC
[Rd] Truncation error on simply mean & sum function (PR#12515
On Fri, Aug 8, 2008 at 7:30 AM, <samaya6501@yahoo.com.tw> wrote:> Full_Name: Tom Wang > Version: 2.6.2 > OS: Linux, Windows > Submission from: (NULL) (61.230.6.228) > > > I've found an instance: > > > a <- c(0.187,-0.019,0.074,-0.06,0.221,-0.079,0.12,0.079,-0.281,-0.242) > > sum(a) > [1] -2.428613e-17 > > The actual sum is 0 but it reports the wrong answer. > > Maybe it is due to the computer truncation error.<https://stat.ethz.ch/mailman/listinfo/r-devel>This is not a bug, but FAQ 7.31. /Christian [[alternative HTML version deleted]]
Thomas Lumley
2008-Aug-08 16:41 UTC
[Rd] Truncation error on simply mean & sum function (PR#12515)
Not a bug. None of these numbers are exactly representable in binary, so you can't expect accuracy of better than machine epsilon. Please don't report things that aren't bugs to r-bugs. -thomas On Fri, 8 Aug 2008, samaya6501 at yahoo.com.tw wrote:> Full_Name: Tom Wang > Version: 2.6.2 > OS: Linux, Windows > Submission from: (NULL) (61.230.6.228) > > > I've found an instance: > >> a <- c(0.187,-0.019,0.074,-0.06,0.221,-0.079,0.12,0.079,-0.281,-0.242) >> sum(a) > [1] -2.428613e-17 > > The actual sum is 0 but it reports the wrong answer. > > Maybe it is due to the computer truncation error. > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle