David M Smith, MathSoft International, writes:
I have to defend S-PLUS here -- this isn't a bug (millennium or otherwise).
The issue is that S-PLUS 5 (unlike previous versions of S-PLUS) uses integer
arithmetic for integer expressions, and in this case the maximum integer
value has been overflowed. The maximum integer depends on the machine being
used; the value is stored in .Machine$integer.max. On this Solaris box, it
is:
> .Machine$integer.max
[1] 2147483647
> 2147483647+1
[1] NA
So while the following expression overflows an integer:
> 60*60*24*365*1000
[1] NA
A more accurate expression for the number of seconds in a millenium (taking
leap years into account) is:
> 60*60*24*365.24*1000
[1] 31556736000
The result here is a float. Specifically, 1000 is an integer, but 1000.0 is
a float (double).
By the way, the usual forum for S-PLUS queries is the s-news mailing list --
see http://www.biostat.wustl.edu/s-news/ for subscription info.
Yours,
Geoff
Dr Geoff Pegler
MathSoft International
Knightway House
Park Street
Bagshot
Surrey GU19 5AQ
United Kingdom
Tel: +44(0)1276 45 22 99 x221
Fax: +44(0)1276 45 12 24
Email: [log in to unmask]
URL: http://www.mathsoft.co.uk/splus
-----Original Message-----
From: [log in to unmask]
[mailto:[log in to unmask]] On Behalf Of Guy Nason
Sent: 11 November 1999 16:22
To: Allstat; [log in to unmask]
Subject: Pre-millenium bug in SPlus5.0
Dear all,
A warning about a pre-millenium bug in Splus5.0 for Sun Solaris which
was brought to my attention by David Draper....
------------------------------------------------
S-PLUS : Copyright (c) 1988, 1998 MathSoft, Inc.
S : Copyright Lucent Technologies, Inc.
Version 5.0 Release 3 for Sun SPARC, SunOS 5.5 : 1998
Working data will be in .Data
>
> 60*60*24*365
[1] 31536000
>
> 60*60*24*365*1000
[1] NA
------------------------------------------------
Regards,
Guy Nason
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|