Extreme numerical values in floating-point precision in R

后端 未结 2 1967
名媛妹妹
名媛妹妹 2020-11-28 13:55

Can somebody please explain me the following output. I know that it has something to do with floating point precision, but the order of magnitue (difference 1e308) surprises

2条回答
  •  清酒与你
    2020-11-28 14:25

    R uses IEEE 754 double-precision floating-point numbers.

    Floating-point numbers are more dense near zero. This is a result of their being designed to compute accurately (the equivalent of about 16 significant decimal digits, as you have noticed) over a very wide range.

    Perhaps you expected a fixed-point system with uniform absolute precision. In practice fixed-point is either wasteful or the ranges of each intermediate computation must be carefully estimated beforehand, with drastic consequences if they are wrong.

    Positive floating-point numbers look like this, schematically:

    +-+-+-+--+--+--+----+----+----+--------+--------+--------+--
    0
    

    The smallest positive normal double-precision number is 2 to the power of the minimal exponent. Near one, the double-precision floating-point numbers are already spread quite wide apart. There is a distance of 2-53 from one to the number below it, and a distance of 2-52 from one to the number above it.

提交回复
热议问题