

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Program to check if a Float is Infinite or Not a Number(NAN)
To check if a Float is isInfinite, use the isInfinite() method and to check for NAN, use the isNaN() method.
Example
public class Demo { public static void main(String[] args) { float value1 = (float) 1 / 0; boolean res1 = Float.isInfinite(value1); System.out.println("Checking for isInfinite? = "+res1); float value2 = (float) Math.sqrt(9); boolean res2 = Float.isNaN(value2); System.out.println("Checking for isNan? = "+res2); } }
Output
Checking for isInfinite? = true Checking for isNan? = false
- Related Questions & Answers
- PHP program to check if a given number is present in an infinite series or not
- JavaScript: How to check if a number is NaN or finite?
- Checking if a double (or float) is NaN in C++
- C# Program to check if a number is prime or not
- Python program to check if a number is Prime or not
- PHP program to check if a number is prime or not
- How to check whether a NaN is a NaN or not in JavaScript?
- Java Program to check if a string is empty or not
- Write a C# program to check if a number is Palindrome or not
- Write a C# program to check if a number is prime or not
- Bash program to check if the Number is a Prime or not
- Java Program to Check Whether a Number is Prime or Not
- Check if a number is a Krishnamurthy Number or not in C++
- Check if a number is jumbled or not in C++
- Check if a number is an Unusual Number or not in C++
Advertisements