Double 类中 NaN、POSITIVE_INFINITY 和其他一些常量的值设置是多少?

Gur*_*ngh 1 java double

NaN为以及类POSITIVE_INFINITY中的其他一些常量设置的值是多少Double?从源代码中,我看到它们被设置为自己,但是这是如何工作的呢?

public final class Double extends Number implements Comparable<Double> {
    public static final double POSITIVE_INFINITY = POSITIVE_INFINITY;
    public static final double NEGATIVE_INFINITY = NEGATIVE_INFINITY;
    public static final double NaN = NaN;
    public static final double MAX_VALUE = MAX_VALUE;
    public static final double MIN_VALUE = MIN_VALUE;

    ...
}
Run Code Online (Sandbox Code Playgroud)

谢谢。

And*_*ner 5

至少在OpenJDK 8OpenJDK 9OpenJDK 10中,它们在源代码中:

public static final double POSITIVE_INFINITY = 1.0 / 0.0;
public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
public static final double NaN = 0.0d / 0.0;  // (*)
public static final double MAX_VALUE = 0x1.fffffffffffffP+1023;
public static final double MIN_VALUE = 0x0.0000000000001P-1022;
Run Code Online (Sandbox Code Playgroud)

(*)如果您想知道“ d”...