![]() |
VOOZH | about |
The java.lang.Math.nextAfter() returns the floating-point number adjacent to the first argument in the direction of the second argument. If both arguments are equal then the second argument is returned.
// datatype can be float or double. public static dataType nextAfter(dataType st, dataType dir)
st : starting floating-point value. dir :value indicating which of start's neighbors or start should be returned.
This method returns the floating-point number adjacent to the start in the direction of the direction.
Note : If one of the arguments is NaN, Output is NaN
- If both arguments are signed zeros, direction is returned unchanged(as implied by the requirement of returning the second argument if the arguments compare as equal).
- If start is Double.MIN_VALUE or Float.MIN_VALUE and direction has a value such that the result should have a smaller magnitude, then a zero with the same sign as start is returned.
- If start is infinite and direction has a value such that the result should have a smaller magnitude, Double.MAX_VALUE or Float.MAX_VALUE with the same sign as start is returned.
- If start is equal to Double.MAX_VALUE or Float.MAX_VALUE and direction has a value such that the result should have a larger magnitude, an infinity with same sign as start is returned.
To show the working of java.lang.Math.nextAfter() method.
NaN 0.0 2.8E-45 3.4028235E38 1.7976931348623155E308
956.4343000000001