问题
I found a bug in my code which boiled down to comparing Double(0.0)
with Double.MIN_VALUE
. Essentially, the following returns false:
System.out.println(0.0 > Double.MIN_VALUE);
How is this possible?
回答1:
According to the javadoc for Double.MIN_VALUE, MIN_VALUE is:
A constant holding the smallest positive nonzero value of type double
So Double.MIN_VALUE is not negative, it's the positive value that's as close as a Double can get to zero (without being zero).
回答2:
Double.MIN_VALUE is the smallest positive non-zero value which can be represented by a Java double (see the JavaDoc at http://download.oracle.com/javase/8/docs/api/java/lang/Double.html).
来源:https://stackoverflow.com/questions/5709073/is-double-min-value-is-greater-than-zero-in-java