[Rd] NAs produced by integer overflow (PR#10482)
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sat Dec 1 14:43:31 CET 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.
Well, it is what happens when you multiply two large integers. How would
you expect it to be "dealt with"? If we are to have a rule that the
product of two integers is an integer, there's no alternative.
Alternatively, the result could be automatically coerced to double and
would then unpredictably be either integer or double.
> Here's my version information:
>
> # -------------------------------------
> 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
>
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-devel
mailing list