Language Basics Java Book

Dividing a negative number by 0.0 outputs -infinity. For example, System.out.println(-1.0/0.0); outputs -Infinity.
public class Main{
public static void main(String[] args) {
System.out.println(-1.0/0.0);
}
}
Output:
-Infinity
Dividing 0.0 by 0.0 returns NaN. square root of a negative number is NaN
For example, System.out.println(0.0/0.0) and System.out.println(Math.sqrt(-1.0)) output NaN.
Dividing a positive number by +infinity outputs +0.0. For example, System.out.println(1.0/(1.0/0.0)); outputs +0.0.
Dividing a negative number by +infinity outputs -0.0. For example, System.out.println(-1.0/(1.0/0.0)); outputs -0.0.
public class Main {
public static void main(String[] args) {
Double d1 = new Double(+0.0);
System.out.println(d1.doubleValue());

Double d2 = new Double(-0.0);
System.out.println(d2.doubleValue());
System.out.println(d1.equals(d2));
System.out.println(+0.0 == -0.0);

}
}
The following code parses command-line arguments into double precision floating-point values
public class Main {
public static void main(String[] args) {
if (args.length != 3) {
System.err.println("usage: java Main value1 op value2");
System.err.println("op is one of +, -, *, or /");
return;
}
try {
double value1 = Double.parseDouble(args[0]);
double value2 = Double.parseDouble(args[2]);
if (args[1].equals("+")) {
System.out.println(value1 + value2);
} else if (args[1].equals("-")) {
System.out.println(value1 - value2);
} else if (args[1].equals("*")) {
System.out.println(value1 * value2);
} else if (args[1].equals("/")) {
System.out.println(value1 / value2);
} else {
System.err.println("invalid operator: " + args[1]);
}
} catch (Exception nfe) {
System.err.println("Bad number format: " + nfe.getMessage());
}
}
}