[R] integer overflow error problem

Robin Hankin r.hankin at auckland.ac.nz
Mon Mar 31 22:47:41 CEST 2003

Hi everyone

As many people pointed out, R is behaving as documented.  The issue
was that a:b has storage mode integer if a is (numerically) equal to
an integer.  Thus:

R> storage.mode(as.double(1.0):3)
[1] "integer"


R> storage.mode(as.double(1.1):3)
[1] "double"
R> storage.mode(1)
[1] "double"

as documented under help(":").

Now _why_ does colon have this behaviour, when it seems that very few
other functions return integers; help(":") gives no clue to the
motivation.  Splus does the same thing (apparently), so there must be
some rationale.  What is it?

Also, it would appear, both "if(2+2==4)" and "(1:10)==4" are
inadvisable, because in both cases, at least one side of the "==" is a
double.  How do I get round this?




Robin Hankin, Lecturer,
School of Geography and Environmental Science
Tamaki Campus
Private Bag 92019 Auckland
New Zealand

r.hankin at auckland.ac.nz
tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042

More information about the R-help mailing list