Float.isNaN() in Java

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

Syntax:

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

This method takes one argument of type float as its parameter. This method returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

Parameters: One parameter is required for this method.

v: the value to be tested.

Returns: true if the argument is NaN; false otherwise.

For Example:

float v = 177.9f

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

Approach

Java

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

        float v = 177.9f;
        System.out.println(Float.isNaN(v));

    }
}

Output:

false

No comments:

Post a Comment