特殊浮点值 Java

java

 

// Finite +-0.0
System.out.println("Finite with +-0.0:");
System.out.println("Finite / +-0.0: " + 8.0 / 0.0);
System.out.println("Finite / +-0.0: " + 8.0 / -0.0);
System.out.println("Finite * +-0.0: " + 8.0 * 0.0);
System.out.println("Finite * +-0.0: " + 8.0 * -0.0);
System.out.println("Finite % +-0.0: " + 8.0 % 0.0);
System.out.println("Finite % +-0.0: " + 8.0 % -0.0);
System.out.println("Finite + +-0.0: " + 8.0 + 0.0);
System.out.println("Finite + +-0.0: " + 8.0 + -0.0);
System.out.println("Finite - +-0.0: " + (8.0 - 0.0));
System.out.println("Finite - +-0.0: " + (8.0 - -0.0));
System.out.println();

Finite with +-0.0:
Finite / +-0.0: Infinity
Finite / +-0.0: -Infinity
Finite * +-0.0: 0.0
Finite * +-0.0: -0.0
Finite % +-0.0: NaN
Finite % +-0.0: NaN
Finite + +-0.0: 8.00.0
Finite + +-0.0: 8.0-0.0
Finite - +-0.0: 8.0
Finite - +-0.0: 8.0


// Finite +-∞
System.out.println("Finite with +-∞:");
System.out.println(8.0 / (1.0 / 0));
System.out.println(8.0 / (-1.0 / 0));
System.out.println(8.0 * (1.0 / 0));
System.out.println(8.0 * (-1.0 / 0));
System.out.println(8.0 % (1.0 / 0));
System.out.println(8.0 % (-1.0 / 0));
System.out.println(8.0 + (1.0 / 0));
System.out.println(8.0 + (-1.0 / 0));
System.out.println(8.0 - (1.0 / 0));
System.out.println(8.0 - (-1.0 / 0));
System.out.println();

Finite with +-∞:
0.0
-0.0
Infinity
-Infinity
8.0
8.0
Infinity
-Infinity
-Infinity
Infinity


// +-0.0 +-0.0
System.out.println("+-0.0 with +-0.0:");
System.out.println(0.0 / 0.0);
System.out.println(0.0 / -0.0);
System.out.println(0.0 * 0.0);
System.out.println(0.0 * -0.0);
System.out.println(0.0 % 0.0);
System.out.println(0.0 % -0.0);
System.out.println(0.0 + 0.0);
System.out.println(0.0 + -0.0);
System.out.println(0.0 - 0.0);
System.out.println(0.0 - -0.0);
System.out.println();

System.out.println(-0.0 / 0.0);
System.out.println(-0.0 / -0.0);
System.out.println(-0.0 * 0.0);
System.out.println(-0.0 * -0.0);
System.out.println(-0.0 % 0.0);
System.out.println(-0.0 % -0.0);
System.out.println(-0.0 + 0.0);
System.out.println(-0.0 + -0.0);
System.out.println(-0.0 - 0.0);
System.out.println(-0.0 - -0.0);
System.out.println();

+-0.0 with +-0.0:
NaN
NaN
0.0
-0.0
NaN
NaN
0.0
0.0
0.0
0.0

NaN
NaN
-0.0
0.0
NaN
NaN
0.0
-0.0
-0.0
0.0


// +-∞ Finite
System.out.println("+-∞ with Finite:");
System.out.println((1.0 / 0) / 8.0);
System.out.println((-1.0 / 0) / 8.0);
System.out.println((1.0 / 0) * 8.0);
System.out.println((-1.0 / 0) * 8.0);
System.out.println((1.0 / 0) % 8.0);
System.out.println((-1.0 / 0) % 8.0);
System.out.println((1.0 / 0) + 8.0);
System.out.println((-1.0 / 0) + 8.0);
System.out.println((1.0 / 0) - 8.0);
System.out.println((-1.0 / 0) - 8.0);
System.out.println();

+-∞ with Finite:
Infinity
-Infinity
Infinity
-Infinity
NaN
NaN
Infinity
-Infinity
Infinity
-Infinity


// +-∞ +-∞
System.out.println("+-∞ with +-∞:");
System.out.println((1.0 / 0) / (1.0 / 0));
System.out.println((-1.0 / 0) / (-1.0 / 0));
System.out.println((1.0 / 0) * (1.0 / 0));
System.out.println((-1.0 / 0) * (-1.0 / 0));
System.out.println((1.0 / 0) % (1.0 / 0));
System.out.println((-1.0 / 0) % (-1.0 / 0));
System.out.println((1.0 / 0) + (1.0 / 0));
System.out.println((-1.0 / 0) + (-1.0 / 0));
System.out.println((1.0 / 0) - (1.0 / 0));
System.out.println((-1.0 / 0) - (-1.0 / 0));
System.out.println();

System.out.println((1.0 / 0) / (-1.0 / 0));
System.out.println((-1.0 / 0) / (1.0 / 0));
System.out.println((1.0 / 0) * (-1.0 / 0));
System.out.println((-1.0 / 0) * (1.0 / 0));
System.out.println((1.0 / 0) % (-1.0 / 0));
System.out.println((-1.0 / 0) % (1.0 / 0));
System.out.println((1.0 / 0) + (-1.0 / 0));
System.out.println((-1.0 / 0) + (1.0 / 0));
System.out.println((1.0 / 0) - (-1.0 / 0));
System.out.println((-1.0 / 0) - (1.0 / 0));
System.out.println();

+-∞ with +-∞:
NaN
NaN
Infinity
Infinity
NaN
NaN
Infinity
-Infinity
NaN
NaN

NaN
NaN
-Infinity
-Infinity
NaN
NaN
NaN
NaN
Infinity
-Infinity

 

// +-0 +-∞
System.out.println("+-0 with +-∞:");
System.out.println(0.0 / (1.0 / 0));
System.out.println(0.0 / (-1.0 / 0));
System.out.println(0.0 * (1.0 / 0));
System.out.println(0.0 * (-1.0 / 0));
System.out.println(0.0 % (1.0 / 0));
System.out.println(0.0 % (-1.0 / 0));
System.out.println(0.0 + (1.0 / 0));
System.out.println(0.0 + (-1.0 / 0));
System.out.println(0.0 - (1.0 / 0));
System.out.println(0.0 - (-1.0 / 0));
System.out.println();

System.out.println(-0.0 / (1.0 / 0));
System.out.println(-0.0 / (-1.0 / 0));
System.out.println(-0.0 * (1.0 / 0));
System.out.println(-0.0 * (-1.0 / 0));
System.out.println(-0.0 % (1.0 / 0));
System.out.println(-0.0 % (-1.0 / 0));
System.out.println(-0.0 + (1.0 / 0));
System.out.println(-0.0 + (-1.0 / 0));
System.out.println(-0.0 - (1.0 / 0));
System.out.println(-0.0 - (-1.0 / 0));
System.out.println();

+-0 with +-∞:
0.0
-0.0
NaN
NaN
0.0
0.0
Infinity
-Infinity
-Infinity
Infinity

-0.0
0.0
NaN
NaN
-0.0
-0.0
Infinity
-Infinity
-Infinity
Infinity

以上是 特殊浮点值 Java 的全部内容, 来源链接: utcz.com/z/392229.html

回到顶部