Javatpoint Logo
Javatpoint Logo

Java Float isNaN() method

The isNaN() method of Java Float class returns a Boolean value for the specified float object or for 'v'. This method returns true if the argument passed is Not a Number (NaN), else returns false.

Syntax:

Parameters:

  1. The parameter passed is 'v' which is of float type.
  2. NA

Return Value:

This method returns a Boolean value for this float object.

  • Returns true, if the argument passed is NaN (Not-a-Number).
  • Returns false, if the arguments passed is anything other than Nan.

Example 1

Test it Now

Output:

1. NaN value = true
2. NaN value = true
3. 0.1 value = false

Example 2

Test it Now

Output:

Enter two float no.
1. Enter Positive float number = 
89
Ans. Square root of 89.0 value = 9.433981
2. Enter Negative float number =
-956
Ans. Square root of -956.0 value = NaN

Example 3

Test it Now

Output:

Enter Positive float number = 
767
1. 767.0/0.0 - 767.0/0.0 = NaN value is true
2. 767.0/0.0 * 0.0 = NaN value is true
3. 767.0*0.0 / 0.0 = NaN value is true
4. NaN - 768943453 = NaN value is true

Next TopicJava Float





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA