- 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
Advertisements