Float.isInfinite() in Java

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

Syntax:

boolean java.lang.Float.isInfinite(float v)

This method takes one argument of type float 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 argument is positive infinity or negative infinity; false otherwise

For Example:

float v = 1919.9f

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

Approach

Java

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

        float v = 1919.9f;
        System.out.println(Float.isInfinite(v));

    }
}

Output:

false

No comments:

Post a Comment