Java.lang.Double.isInfinite() Method
Advertisements
Description
The java.lang.Double.isInfinite(double v) method returns true if the specified number is infinitely large in magnitude, false otherwise.The argument v is the value to be tested.
Declaration
Following is the declaration for java.lang.Double.isInfinite() method
public static boolean isInfinite(double v)
Parameters
v -- This is the value to be tested.
Return Value
This method returns true if the value of the argument is positive infinity or negative infinity; false otherwise.
Exception
NA
Example
The following example shows the usage of java.lang.Double.isInfinite() method.
package com.tutorialspoint;
import java.lang.*;
public class DoubleDemo {
public static void main(String[] args) {
Double d1 = new Double(1.0/0.0);
Double d2 = new Double(0.0/0.0);
// returns true if positive or negative infinity
System.out.println(d1 + " = " + d1.isInfinite(d1));
// returns false for other cases
System.out.println(d2 + " = " + d2.isInfinite(d2));
}
}
Let us compile and run the above program, this will produce the following result:
Infinity = true NaN = false