import java.lang.Math; public class testInf { public static void main(String[] args) { double x, y, z; test(1.0, 0.0); // generate a positive Infinity test(-1.0, 0.0); // generate a negative Infinity } public static void test(double x, double y) { double z = x/y; System.out.println("This line should read: " + x + "/" + y + " -> Inf"); System.out.println(x + "/" + y + " -> " + z); if (z != z) System.out.println("Incorrect comparison of Infinities with !="); if (z == z) System.out.println("Correct comparison of Infinities with =="); if (!Double.isInfinite(z)) System.out.println("Incorrect test of Infinities with isInfinite()"); if (Double.isInfinite(z)) System.out.println("Correct test of Infinities with isInfinite()"); } }