java.lang.Double isInfinite(double v)
Syntax:
public static boolean isInfinite(double v)
Java Code Example :
This java example source code demonstrates the use of isInfinite(double v) method of Double class. This method returns true if the specified number is infinitely large in magnitude, false otherwise.
On this example we will evaluate numbers and check if the values are infinite or not.
package com.javatutorialhq.java.examples; /* * This example source code demonstrates the use of static method * isInfinite(double v) of Double class */ public class DoubleIsInfiniteDouble { public static void main(String[] args) { double value1 = 325.25 / 0.0; double value2 = -325.25 / 0.0; double value3 = 125.3; double value4 = value3 / 0.0; double value5 = value1 / value2; System.out.println(value1 + " isInfinite: " + Double.isInfinite(value1)); System.out.println(value2 + " isInfinite: " + Double.isInfinite(value2)); System.out.println(value3 + " isInfinite: " + Double.isInfinite(value3)); System.out.println(value4 + " isInfinite: " + Double.isInfinite(value4)); System.out.println(value5 + " isInfinite: " + Double.isInfinite(value5)); } }
Sample Output :
Running the above example source code will give the following output