nextUp(): This method is available in the Math class of Java.
Syntax:
double java.lang.Math.nextUp(double d)
This method takes one argument of type double as its parameter. This method returns the floating-point value adjacent to d in the direction of positive infinity.
Special Cases:
1. If the argument is NaN, the result is NaN.
2. If the argument is positive infinity, the result is positive infinity.
3. If the argument is zero, the result is Double.MIN_VALUE.
Parameters: One parameter is required for this method.
d: starting floating-point value.
Returns: The adjacent floating-point value closer to positive infinity.
For Example:
For Example:
Math.nextUp(1919.919) = > It returns 1919.9190000000003
Approach
Java
public class NextUpDouble {public static void main(String[] args) {double d = 1919.919;System.out.println(Math.nextUp(d));}}
Output:
1919.9190000000003
No comments:
Post a Comment