StrictMath.nextUp(double) in Java

StrictMath.nextUp(double): This method is available in java.lang.StrictMath class of Java.

Syntax:

double java.lang.StrictMath.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.

Note:

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.

Exceptions: NA

Approach

Java

public class StrictMathnextUpdouble {
    public static void main(String[] args) {

        double d = 1991.94;
        System.out.println(StrictMath.nextUp(d));
    }
}

Output:

1991.9400000000003


No comments:

Post a Comment