如果一个数字被R中的另一个太小的数字除会怎样

如果一个数字被R中的另一个太小的数字除会怎样,r,nan,arbitrary-precision,R,Nan,Arbitrary Precision,我已经尝试过1e-324在R中基本上为零。那么,当我想做这样的计算时,我应该怎么做: 1e-2000/1e-2000 #[1] NaN #But the real value should be 1 因此,我们非常感谢您的帮助。您需要任意精度的算术运算。看看gmp: 你需要任意精度的算术。看看gmp: library(gmp) divide_by_zero <- function(n) {10^n / 10^n} divide_by_nonzero <- function(n) {

我已经尝试过1e-324在R中基本上为零。那么,当我想做这样的计算时,我应该怎么做:

1e-2000/1e-2000
#[1] NaN
#But the real value should be 1

因此,我们非常感谢您的帮助。

您需要任意精度的算术运算。看看gmp:


你需要任意精度的算术。看看gmp:

library(gmp)
divide_by_zero <- function(n) {10^n / 10^n}
divide_by_nonzero <- function(n) {pow.bigz(10, n) / pow.bigz(10, n)}
divide_by_zero(-320:-330)
# [1]   1   1   1   1 NaN NaN NaN NaN NaN NaN NaN
divide_by_nonzero(-320:-330)
#Big Rational ('bigq') object of length 11:
# [1] 1 1 1 1 1 1 1 1 1 1 1