StrictMath.min(float, float) in Java

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

Syntax:

float java.lang.StrictMath.min(float a, float b)

This method takes two arguments of type float as its parameters. This method returns the smaller of two float values. That is, the result is the value closer to negative infinity.

Note:

1. If the arguments have the same value, the result is the same value.

2. If either value is NaN, then the result is NaN.

Parameters: Two parameters are required for this method.

a: an argument.

b: another argument.

Returns: the smaller of a and b.

Exceptions: NA

Approach

Java

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

        float a = 178.89f, b = 199.6f;
        System.out.println(StrictMath.min(a, b));
    }
}

Output:

178.89


Some more min() Methods of StrictMath class.


StrictMath.min(double, double)


StrictMath.min(int, int)


StrictMath.min(long, long)


No comments:

Post a Comment