FW: [Rd] sum overflow (PR#1091)

Warnes, Gregory R gregory_r_warnes@groton.pfizer.com
Thu, 13 Sep 2001 16:45:37 -0400

> From: David Smith [mailto:dsmith@insightful.com]
>> From: Prof Brian Ripley
>> If you use integers you need to be aware of the consequences.  It's a
>> feature not a bug.
> Perhaps, but maybe a more useful feature would be to signal to the user
> such an overflow occurs?  Sv4 does this by returning NA for overflow
> results:
> > a <- (1:1000)
> > b <- (1:1000)
> > sum(a * a) * sum(b * b)
> [1] NA
> When this was introduced in S-PLUS 5, we discovered some overflow errors
> were previously unaware of in S-PLUS (by noticing NAs in the results).

This is a first step in the right direction.  I think that having overflows
generate of NA's should be augmented by a warning or an error message.
Thus we would get something like:

> a <- (1:1000)
> b <- (1:1000)
> sum(a * a) * sum(b * b)
Warning messages: 
Integer overflow produced NA's in: .Primitive("*") 
> [1] NA

Now, the problem will be clear to the user, and many users will immediately
see how to get around it.


Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch