In fact, the IEEE 754 floating point architecture simplifies: thanks to the standard, the function is called nextafter in almost all languages ββthat support it, and this uniformity allowed me to write the answer to your question with very little familiarity with Java:
java.lang.Math.nextAfter(double start, double direction) returns a floating-point number adjacent to the first argument in the direction of the second argument.
Remember that -infinity and + infinity are floating point values, and these values ββare convenient for specifying the direction (second argument). Do not make a general mistake when writing something like Math.nextAfter(x, x+1) , which only works as long as 1 is greater than ULP x .
Anyone who writes above most likely means Math.nextAfter(x, Double.POSITIVE_INFINITY) , which saves addition and works for all x values.
source share