Skip to content
Prev 374541 / 398513 Next

NAs produced by integer overflow, but only some time ...

Printing a number does not show whether it is stored
as a 32-bit integer or as a 64-bit floating point value.
Use. e.g.,  str() or class() to see.
  > str(length(runif(3)))
   int 3
  > str(length(runif(3)) + 1)
   num 4
  > str(length(runif(3)) + 1L)
   int 4
  > str( 3L * 3L )
   int 9
  > str( 3L ^ 2L )
   num 9
You are right that various arithmetic operators map a pair
of integer arguments to various type: the power and division
operators map them to double precision while the the addition,
multiplication, and subtraction operators map them to integer
results (giving NA's if the result cannot fit into 32 bits).
Perhaps it was a mistake to include the integer type, but
at the time S was developed it made sense.

As for table(table(x)) being an unnatural construct, I use it
all the time instead of anyDuplicated to see the pattern of
duplications.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, May 9, 2018 at 12:04 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
wrote: