[Rd] inconsistent overflow handling by strtoi() on 32-bit Windows

From: William Dunlap <wdunlap_at_tibco.com>
Date: Tue, 10 Jan 2012 16:52:39 +0000


Using the precompiled R 2.14.1 on 32-bit Windows XP strtoi(x) gives 2^31-1 for x>2^31-1 but NA when x goes out of range in the negative direction:

> x <- c("2147483646", "2147483647", "2147483648", "2147483649")
> str(strtoi(x))

 int [1:4] 2147483646 2147483647 2147483647 2147483647
> str(strtoi(sprintf("-%s", x)))

 int [1:4] -2147483646 -2147483647 NA NA

> sessionInfo()

R version 2.14.1 (2011-12-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:

[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
ink1">[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base  

On 64-bit Linux overflow in the either direction gives NA.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 10 Jan 2012 - 16:54:52 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 Jan 2012 - 17:00:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive