William Dunlap
2012-Jan-10 16:52 UTC
[Rd] inconsistent overflow handling by strtoi() on 32-bit Windows
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 [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