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

2011-12-15 Thread peter dalgaard
On Dec 15, 2011, at 02:51 , Hervé Pagès wrote: Hi Peter, On 11-12-14 08:19 AM, peter dalgaard wrote: On Dec 14, 2011, at 16:19 , John C Nash wrote: Following this thread, I wondered why nobody tried cumsum to see where the integer overflow occurs. On the shorter xx vector in the

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

2011-12-15 Thread Martin Maechler
peter dalgaard pda...@gmail.com on Thu, 15 Dec 2011 11:40:23 +0100 writes: On Dec 15, 2011, at 02:51 , Hervé Pagès wrote: Hi Peter, On 11-12-14 08:19 AM, peter dalgaard wrote: On Dec 14, 2011, at 16:19 , John C Nash wrote: Following this

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

2011-12-15 Thread Hervé Pagès
Hi Duncan, On 11-12-14 03:57 AM, Duncan Murdoch wrote: On 11-12-13 6:41 PM, Hervé Pagès wrote: Hi Duncan, On 11-12-10 05:27 AM, Duncan Murdoch wrote: On 11-12-09 4:41 PM, Hervé Pagès wrote: Hi Duncan, On 11-12-09 11:39 AM, Duncan Murdoch wrote: On 09/12/2011 1:40 PM, Hervé Pagès wrote:

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

2011-12-14 Thread Duncan Murdoch
On 11-12-13 6:41 PM, Hervé Pagès wrote: Hi Duncan, On 11-12-10 05:27 AM, Duncan Murdoch wrote: On 11-12-09 4:41 PM, Hervé Pagès wrote: 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,

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

2011-12-14 Thread John C Nash
Following this thread, I wondered why nobody tried cumsum to see where the integer overflow occurs. On the shorter xx vector in the little script below I get a message: Warning message: Integer overflow in 'cumsum'; use 'cumsum(as.numeric(.))' But sum() does not give such a warning, which I

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

2011-12-14 Thread peter dalgaard
On Dec 14, 2011, at 16:19 , John C Nash wrote: Following this thread, I wondered why nobody tried cumsum to see where the integer overflow occurs. On the shorter xx vector in the little script below I get a message: Warning message: Integer overflow in 'cumsum'; use

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

2011-12-14 Thread John C Nash
I agree that where the overflow occurs is not critical (one can go back to cumsum and find out). I am assuming that Uwe still wants to know there has been an overflow at some point i.e., a warning. This could become more interesting as parallel computation causes different summation orderings

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

2011-12-14 Thread Uwe Ligges
On 14.12.2011 22:16, John C Nash wrote: I agree that where the overflow occurs is not critical (one can go back to cumsum and find out). I am assuming that Uwe still wants to know there has been an overflow at some point i.e., a warning. Yes, sure. Uwe This could become more

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

2011-12-14 Thread Hervé Pagès
Hi Peter, On 11-12-14 08:19 AM, peter dalgaard wrote: On Dec 14, 2011, at 16:19 , John C Nash wrote: Following this thread, I wondered why nobody tried cumsum to see where the integer overflow occurs. On the shorter xx vector in the little script below I get a message: Warning message:

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

2011-12-13 Thread Ted Harding
[See at end] On 13-Dec-11 23:41:12, Hervé Pagès wrote: Hi Duncan, On 11-12-10 05:27 AM, Duncan Murdoch wrote: On 11-12-09 4:41 PM, Hervé Pagès wrote: 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),

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

2011-12-13 Thread Hervé Pagès
Hi Ted, On 11-12-13 04:52 PM, (Ted Harding) wrote: [...] Now, computer programs for numerical computation can broadly be divided into two types. In one, arbitrary precision is available: you can tell the program how many decimal digits you want it to work to. An example of this is 'bc':

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

2011-12-10 Thread Duncan Murdoch
On 11-12-09 4:41 PM, Hervé Pagès wrote: 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

[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):

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

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