StrictMath.nextDown(double) in Java

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

Syntax:

double java.lang.StrictMath.nextDown(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 negative infinity.

Note:

1. If the argument is NaN, the result is NaN.

2. If the argument is negative infinity, the result is negative 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 negative infinity.

Exceptions: NA

Approach

Java

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

        double d = 18819.56;
        System.out.println(StrictMath.nextDown(d));
    }
}

Output:

18819.559999999998


No comments:

Post a Comment