I learned this from the Java documentation
It basically says that:
Returns the floating-point value adjacent to d in the direction of positive infinity.
and especially:
If the argument is zero, the result is Double.MIN_VALUE
With this logic:
Math.nextUp(double x) - x
should always be Double.MIN_VALUE
.
So I tested it out:
double d_up = Math.nextUp(0);
System.out.println(d_up); // 1.401298464324817E-45
System.out.println(d_up == Double.MIN_VALUE); // false
System.out.println(Double.MIN_VALUE); // 4.9E-324
and it doesn't even work with zero.
Why does Math.nextUp(double x)
not equal x + Double.MIN_VALUE
?