[R] integer overflow error problem

Prof. Brian Ripley ripley at stats.ox.ac.uk
Mon Mar 31 22:57:12 CEST 2003


On Tue, 1 Apr 2003, Robin Hankin wrote:

[...]

> 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?

If you mean integers, it helps to have them to avoid rounding errors.
S-PLUS (sic) currently thinks 20 is integer and 20. is double.

> 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?

?identical
?as.equal

BTW, == does coerce as needed, so 2+2==as.integer(4) is fine.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list