In 2.8.1/Windows:

According to ? :

     Details:
     For numeric arguments 'from:to' is equivalent to 'seq(from, to)' ...

     Value:
     For numeric arguments, a numeric vector.  This will be of type
     'integer' if 'from' and 'to' are both integers and representable
     in the integer type, otherwise of type 'numeric'....

The first claim is inconsistent with the second; it appears that the first
one is true and the second is false.

Actual behavior:

   storage.mode(1:2.5) => integer
   storage.mode(`:`(from=1L,to=2.5)) => integer   # just to be completely
explicit

But of course 2.5 is not an integer or equal to one.

This is the same behavior as seq:

   storage.mode(seq(1,2.5)) => integer
   storage.mode(seq(from=1L,to=2.5)) => integer

---------------------------------

On the other hand, according to ? seq

     Currently, the default method returns a result of type '"integer"'
     if 'from' is (numerically equal to an) integer

This is not correct:

> seq(1e16,1e16+10)
 [1] 1e+16 1e+16 1e+16 1e+16 1e+16 1e+16 1e+16 1e+16 1e+16 1e+16 1e+16
> seq(1e16,1e16+10)-1e16
 [1]  0  0  2  4  4  4  6  8  8  8 10   # not enough precision to represent
all the distinct integers, OK
> storage.mode(seq(1e16,1e16+10))
[1] "double"

In this case, the ? : documentation is correct:

     This will be of type 'integer' if ... representable in the integer
type, otherwise of type 'numeric'.

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to