Difference between Java's `Double.MIN_NORMAL` and `Double.MIN_VALUE`?

后端 未结 3 1528
星月不相逢
星月不相逢 2020-12-05 12:46

What\'s the difference between Double.MIN_NORMAL (introduced in Java 1.6) and Double.MIN_VALUE?

3条回答
  •  没有蜡笔的小新
    2020-12-05 13:35

    For simplicity, the explanation will consider just the positive numbers.

    The maximum spacing between two adjacent normalized floating point numbers 'x1' and 'x2' is 2 * epsilon * x1 (the normalized floating point numbers are not evenly spaced, they are logarithmically spaced). That means, that when a real number (i.e. the "mathematical" number) is rounded to a floating point number, the maximum relative error is epsilon, which is a constant called machine epsilon or unit roundoff, and for double precision it has the value 2^-52 (approximate value 2.22e-16).

    The floating point numbers smaller than Double.MIN_NORMAL are called subnormals, and they are evenly filling the gap between 0 and Double.MIN_NORMAL. That means that the computations involving subnormals can lead to less accurate results. Using subnormals allows a calculation to lose precision more slowly when the result is small.

提交回复
热议问题