NAs produced by integer overflow + R on linux

后端 未结 3 1310
栀梦
栀梦 2021-01-13 18:56

I\'m running an R script on UNIX based system , the script contain multiplication of large numbers , so the results where NAs by integer overflow , but when i run the same s

3条回答
  •  轮回少年
    2021-01-13 19:13

    Given your comments, I guess that you seriously misunderstand the "correctness" of numbers in R. You say the outcome you get on Windows is something like -30598395869593930593. Now, on both 32bit and 64bit that precision is even not possible using a double, let alone using an integer :

    > x <- -30598395869593930593
    > format(x,scientific=F)
    [1] "-30598395869593931776"
    > all.equal(x,as.numeric(format(x,scientific=F)))
    [1] TRUE
    > as.integer(x)
    [1] NA
    

    You have 16 digits you can trust, all the rest is bollocks. Then again, an accuracy of 16 digits is already pretty strong. Most measurement tools don't even come close to that.

提交回复
热议问题