min() double in Java

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

Syntax:

double java.lang.Math.min(double a, double b)

This method takes two arguments of type double as its parameters. This method returns the smaller of two double 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(1818.2929,1991.8282) = > It returns 1818.2929

Approach

Java

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

        double a = 1818.2929, b = 1991.8282;
        System.out.println(Math.min(a, b));

    }
}

Output:

1818.2929

No comments:

Post a Comment