Displaying 1 result from an estimated 1 matches for "sumerr".
Did you mean:
sumeru
2011 Dec 09
3
bug in sum() on integer vector
Hi,
x <- c(rep(1800000003L, 10000000), -rep(1200000002L, 15000000))
This is correct:
> sum(as.double(x))
[1] 0
This is not:
> sum(x)
[1] 4996000
Returning NA (with a warning) would also be acceptable for the latter.
That would make it consistent with cumsum(x):
> cumsum(x)[length(x)]
[1] NA
Warning message:
Integer overflow in 'cumsum'; use