Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

java
double
finite
communitycreator

What is Double.isFinite() in Java?

abhilash

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The isFinite() method of the Double class returns true if the argument is a finite floating-point value, and returns false otherwise (for NaN and infinity arguments).

Method signature

public static boolean isFinite(double d)

Parameters

  • double d: the value to be tested.

Example

In the example below, we define two double values. One is an exponential number, and the other is the result of division by zero. The two double values are tested by the Double.isFinite() method.

import java.lang.Double;
public class Main {
public static void main(String args[])
{
Double d1 = 2E23;
Double d2 = d1/0;
System.out.println(d1 + " - " + Double.isFinite(d1));
System.out.println(d2 + " - " + Double.isFinite(d2));
}
}

RELATED TAGS

java
double
finite
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring