[R] Floating point imprecision in sum() under R-2.3.1?

2006-08-18 Thread Brahm, David
After upgrading to R-2.3.1 on Linux Redhat, I was suprised by this: R x - c(721.077, 592.291, 372.208, 381.182) R sum(x) - 2066.758 [1] 4.547474e-13 Now I understand that floating point arithmetic is not precise, but 1) the result is exactly 0 in R-2.2.1 (patched) on the same machine, 2)

Re: [R] Floating point imprecision in sum() under R-2.3.1?

2006-08-18 Thread Roger D. Peng
I think you want to look at sum(x)/2066.758 - 1 which on my Linux box is 2.2e-16. -roger Brahm, David wrote: After upgrading to R-2.3.1 on Linux Redhat, I was suprised by this: R x - c(721.077, 592.291, 372.208, 381.182) R sum(x) - 2066.758 [1] 4.547474e-13 Now I understand that

Re: [R] Floating point imprecision in sum() under R-2.3.1?

2006-08-18 Thread Brahm, David
I was concerned by this result (new in R-2.3.1): R x - c(721.077, 592.291, 372.208, 381.182) R sum(x) - 2066.758 [1] 4.547474e-13 But after Roger Peng's [EMAIL PROTECTED] insightful comment that the relative difference (sum(x)/2066.758 - 1) is exactly what is expected, I'm convinced that sum()

Re: [R] Floating point imprecision in sum() under R-2.3.1?

2006-08-18 Thread Berton Gunter
But after Roger Peng's [EMAIL PROTECTED] **insightful** comment that the ... but as we are not in that other S language dialect, maybe it should be his **peRceptive** comment. ;-) (Sorry -- it's Friday) -- Bert Gunter __ R-help@stat.math.ethz.ch