- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Float isNaN() Method
The isNan() method returns true if the Float value is a Not-a-Number (NaN). Let’s say we have the following Float values.
Float f1 = new Float(5.0/0.0); Float f2 = new Float(10.2/0.0); Float f3 = new Float(0.0/0.0);
Check with isNaN() method.
f1.isNaN (); f2.isNaN (); f3.isNaN ();
The following is the complete example with output.
Example
import java.lang.*; public class Demo { public static void main(String args[]) { Float f1 = new Float(5.0/0.0); Float f2 = new Float(10.2/0.0); Float f3 = new Float(0.0/0.0); System.out.println(f1.isNaN()); System.out.println(f2.isNaN()); System.out.println(f3.isNaN()); System.out.println(f1.isInfinite()); System.out.println(f2.isInfinite()); System.out.println(f3.isInfinite()); } }
Output
false false true true true false
- Related Articles
- Double isNaN() method in Java
- Java Float isInfinite() Method
- isNAN() function in JavaScript
- Java Float Wrapper Class
- Comparison of Float in Java
- How to convert Float array list to float array in Java?
- Why is isNaN(null) == false in JS?
- Java Program to compare Two Java float Arrays
- Java Program to convert Java String to Float Object
- Check for illegal number with isNaN() in JavaScript
- Round float and double numbers in Java
- Generate Random Float type number in Java
- Java Program to convert float to String
- Convert from float to String in Java
- Convert from String to float in Java

Advertisements