In a longer script, I need to multiply the length of the vector A (2614) with the row numbers of the data block B (1456000). If I do this directly using length(A) * nrow(B) , I get the message NAs produced by integer overflow , although there is no problem multiplying the same numbers:
2614 * 1456000 [1] 3805984000
The only way to get multiplication by work is round(length(A)) * nrow(B) or length(A) * round(nrow(B)) . But the numbers created by length and nrow must be integers as you like! Moreover, I checked this with the following function suggested on the help page for the is.integer function ...
is.wholenumber <- function(x, tol = .Machine$double.eps^0.5) abs(x-round(x)) < tol
... and, of course, they are whole. So why do I need round crutches here? Very puzzling ... Does anyone have an idea what is going on in the background?
r integer-overflow
user7417
source share