101
Java Math.nextAfter() method
The java.lang.Math.nextAfter() returns the floating-point number adjacent to the first argument in the direction of the second argument. If both first argument and second argument are same then this method will return second argument.
Syntax:
Parameters:
Return:
- If either argument is a NaN, this method will return NaN.
- If both arguments are signed zero, the direction will be unchanged.
- If start argument(a) is equal to positive or negative Double.MIN_VALUE or Float.MIN_VALUE and direction argument(b) has a value such that the result should have a smaller magnitude, this method will return Zero with same sign as the argument.
- If start argument(a) is equal to positive or negative Double.MAX_VALUE or Float.MAX_VALUE and direction argument(b) has a value such that the result should have a lager magnitude, this method will return Infinite with same sign as the argument.
- If start argument(a) is infinity and the direction argument(b) has a value such that the result should have a smaller magnitude, then this method will return Double.MAX_VALUE with same sign.
Example 1
Output:
84352.23999999999 154.28400000000002
Example 2
Output:
787.84296
Example 3
Output:
1.0E-323
Example 4
Output:
3.4028233E38
Next TopicJava Math