StrictMath.nextDown(float) in Java

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

Syntax:

float java.lang.StrictMath.nextDown(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 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 -Float.MIN_VALUE

Parameters: One parameter is required for this method.

f: starting floating-point value.

Returns: The adjacent floating-point value closer to negative infinity.

Exceptions: NA

Approach

Java

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

        float f = 8818.56f;
        System.out.println(StrictMath.nextDown(f));
    }
}

Output:

8818.559


No comments:

Post a Comment