Java: Test whether a given double/float value is a finite floating-point value or not
Check Finite Floating-Point Value
Write a Java program to test whether a given double/float value is a finite floating-point value or not.
Sample Solution:
Java Code:
Sample Output:
inite doubles -------------- Is 2.13456321E-4 is finite? true Is Infinity (dn1/0) is finite? false Is NaN is finite? false Finite floats ------------- Is 5.3 is finite? true Is Infinity (fn1/0) is finite? false Is NaN is finite? false
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Java program to determine whether a given floating-point number is finite, infinite, or NaN without using built-in methods.
- Write a Java program to check a list of floating-point numbers for finiteness and then count how many are non-finite.
- Write a Java program to validate floating-point inputs and display custom messages for infinite and NaN values.
- Write a Java program to simulate arithmetic operations on floating-point numbers and check the finiteness of the result after each operation.
Java Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a Java program to break an integer into a sequence of individual digits.
Next: Write a Java program to compare two given signed and unsigned numbers.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.