Double.isInfinite() in Java

Double.isInfinite(): This method is available in java.lang.Double class of Java.

Syntax:

boolean java.lang.Double.isInfinite(double v)

This method takes one argument of type double as its parameter. This method returns true if the specified number is infinitely large in magnitude, false otherwise.

Parameters: One parameter is required for this method.

v: the value to be tested.

Returns: true if the value of the argument is positive infinity or negative infinity; false otherwise.

For Example:

double v = 1919.9

Double.isInfinite(v) = > It returns false.

Approach

Java

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

        double v = 1919.9;
        System.out.println(Double.isInfinite(v));

    }
}

Output:

false

No comments:

Post a Comment