s-news
[Top] [All Lists]

Re: multiplication problem - what happens at 46341?

To: Sundar Dorai-Raj <sundar.dorai-raj@pdf.com>
Subject: Re: multiplication problem - what happens at 46341?
From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
Date: Sun, 5 Mar 2006 08:22:37 +0000 (GMT)
Cc: Brian S Cade <brian_cade@usgs.gov>, s-news@lists.biostat.wustl.edu
In-reply-to: <4408AE87.5070101@pdf.com>
References: <OF3EC1F54F.7E203136-ON87257126.00720B14-87257126.0072753A@usgs.gov> <4408AE87.5070101@pdf.com>
On Fri, 3 Mar 2006, Sundar Dorai-Raj wrote:

Brian S Cade wrote:

Okay, so if this an issue of integer vs double precision real storage, why is this same calculation not a problem in R. What is done differently between S-Plus and R? Curious to avoid future problems.

The difference is between S-PLUS < 5 and R on one hand, and S-PLUS >= 5 on the other. Prior to S-PLUS 5, S stored all parsed numbers as doubles, and R still does.


Brian


Because of this:

S-PLUS 6.2:
storage.mode(46432)
[1] "integer"
storage.mode(46342*46342)
[1] "integer"

R 2.2.1:
storage.mode(46432)
[1] "double"
storage.mode(46342*46342)
[1] "double"

and also

x <- as.integer(46432)
x * x
[1] NA
Warning message:
NAs produced by integer overflow in: x * x

Adding such a warning in S-PLUS would it seems be helpful.

--
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

<Prev in Thread] Current Thread [Next in Thread>