[Rd] bug in sum() on integer vector

2011-12-09 Thread Hervé Pagès
Hi, x <- c(rep(180003L, 1000), -rep(120002L, 1500)) 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)[lengt

Re: [Rd] bug in sum() on integer vector

2011-12-09 Thread Duncan Murdoch
On 09/12/2011 1:40 PM, Hervé Pagès wrote: Hi, x<- c(rep(180003L, 1000), -rep(120002L, 1500)) 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 m

Re: [Rd] bug in sum() on integer vector

2011-12-09 Thread Hervé Pagès
Hi Duncan, On 11-12-09 11:39 AM, Duncan Murdoch wrote: On 09/12/2011 1:40 PM, Hervé Pagès wrote: Hi, x<- c(rep(180003L, 1000), -rep(120002L, 1500)) This is correct: > sum(as.double(x)) [1] 0 This is not: > sum(x) [1] 4996000 Returning NA (with a warning) would also be acce