StrictMath.floor() in Java

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

Syntax:

double java.lang.StrictMath.floor(double a)

This method takes one argument of type double as its parameter. This method returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.

Special cases:

1. If the argument value is already equal to a mathematical integer, then the result is the same as the argument.

2. If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.

Parameters: One parameter is required for this method.

a: a value.

Returns: the largest (closest to positive infinity) floating-point value that is less than or equal to the argument is equal to a mathematical integer.

Exceptions: NA

Approach

Java

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

        double a = -178.89;
        System.out.println(StrictMath.floor(a));
    }
}

Output:

-179.0


No comments:

Post a Comment