[Rd] NAs produced by integer overflow (PR#10482)
ripley at stats.ox.ac.uk
ripley at stats.ox.ac.uk
Sat Dec 1 14:55:15 CET 2007
What is the bug here? You haven't told us what you think it is, and
> 110231L * 101347L
[1] NA
Warning message:
In 110231L * 101347L : NAs produced by integer overflow
is both intentional and documented: see ?Arithmetic.
Please do give a reproducible example (as we ask): yours is not as we
have to guess the types of the objects (I can get similar results if I
guess "integer", but not quite the same).
cur.obs <- 110231L
colfreq <- as.integer(c(14845,1222,4776,101347,2863))
names(colfreq) <- c("other","past","perfect","present","progressive")
sum(cur.obs)*(colfreq/sum(colfreq))
other past perfect present progressive
13085.485 1077.162 4209.921 89334.771 2523.661
sum(cur.obs)*colfreq/sum(colfreq)
other past perfect present progressive
13085.485 1077.162 4209.921 NA 2523.661
Warning message:
In sum(cur.obs) * colfreq : NAs produced by integer overflow
Note the fourth entry.
On Sat, 1 Dec 2007, stgries at gmail.com wrote:
> Full_Name: Stefan Th. Gries
> Version: R version 2.6.1 (2007-11-26)
> OS: Windows XP Home SP2
> Submission from: (NULL) (68.6.47.105)
>
>
> Hi
>
> A simple computation results in integer overflow:
>
> These are the relevant vectors:
>
>> sum(cur.obs)
> [1] 110231
>
>> colfreq
> other past perfect present progressive
> 14845 1222 4776 101347 2863
>
>> sum(colfreq)
> [1] 125053
>
> Now ...
>
> # this works ...
>> sum(cur.obs)*(colfreq/sum(colfreq)) # note: brackets around the division
> other past perfect present progressive
> 13085.485 1077.162 4209.921 89334.771 2523.661
>
> # and this doesn't ...
>> sum(cur.obs)*colfreq/sum(colfreq) # note: no brackets around the division
> other past perfect present progressive
> 13085.485 1077.162 4209.921 2523.661
> Warning message:
> In sum(cur.obs) * colfreq : NAs produced by integer overflow
>
>
>
> I saw this was reported for R 2.3.0 and 2.6.0 before, but I don't know whether
> it ever got dealt with. Here's my version information:
Please don't be vague: you need to give URLs for claims that something is
'reported'.
> # -------------------------------------
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 6.1
> year 2007
> month 11
> day 26
> svn rev 43537
> language R
> version.string R version 2.6.1 (2007-11-26)
> # -------------------------------------
>
> STG
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Brian D. Ripley, ripley at 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
More information about the R-devel
mailing list