min() float in Java

min(): This method is available in the Math class of Java.

Syntax:

 float java.lang.Math.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 that 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.

For Example:

Math.min(17.6,16.88) = > It returns 16.88

Approach

Java

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

        float a = (float17.6, b = (float16.88;
        System.out.println(Math.min(a, b));

    }
}

Output:

16.88

No comments:

Post a Comment