[Rd] inaccurate integer conversion in coercion

Hervé Pagès hpages at fhcrc.org
Tue Oct 27 21:25:38 CET 2009


Hi,

 > as.integer(10000000000)  # 10 billions
[1] NA
Warning message:
NAs introduced by coercion

 > as.integer(-10000000000)  # minus 10 billions
[1] NA
Warning message:
NAs introduced by coercion

 > as.integer("10000000000")  # 10 billions as a string
[1] 2147483647
Warning message:
inaccurate integer conversion in coercion

 > as.integer("-10000000000")  # minus 10 billions as a string
[1] NA
Warning message:
inaccurate integer conversion in coercion

Why is the "10 billions as a string" case treated differently?
(coerced to INT_MAX-1)

And for the "minus 10 billions as a string" case, is the warning
message really appropriate? Why isn't it just the usual "NAs
introduced by coercion"?

Thanks,
H.



More information about the R-devel mailing list