nextUp(): This method is available in the Math class of Java.
Syntax:
float java.lang.Math.nextUp(float f)
This method takes one argument of type float as its parameter. This method returns the floating-point value adjacent to f 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 Float.MIN_VALUE.
Parameters: One parameter is required for this method.
f: starting floating-point value.
Returns: The adjacent floating-point value closer to positive infinity.
For Example:
Math.nextUp(19.9) = > It returns 19.900002
Approach
Java
public class NextUpFloat {public static void main(String[] args) {float f = (float) 19.9;System.out.println(Math.nextUp(f));}}
Output:
19.900002
No comments:
Post a Comment