| Arithmetic Operation | Result: Java Arithmetic | Result: JxnSafePrimitiveArithmetic |
| JXN command: | JxnPrimitiveWrapper.setPluggable( "Java" ) | JxnPrimitiveWrapper.setPluggable( "Safe" ) |
| JXN: type conversion avoids over-/underflow: |
| Integer.MIN_VALUE − 1 | 2147483647 (int) **underflow** | −2147483649 (long) switch to long |
| Integer.MIN_VALUE + 1 | −2147483647 (int) | −2147483647 (int) |
| Integer.MAX_VALUE − 1 | 2147483646 (int) | 2147483646 (int) |
| Integer.MAX_VALUE + 1 | −2147483648 (int) **overflow** | 2147483648 (long) switch to long |
| Long.MIN_VALUE − 1 | 9223372036854775807 (long) **underflow** | −9.223372036854776E18 (double) |
| Long.MIN_VALUE + 1 | −9223372036854775807 (long) | −9223372036854775807 (long) |
| Long.MAX_VALUE − 1 | 9223372036854775806 (long) | 9223372036854775806 (long) |
| Long.MAX_VALUE + 1 | −9223372036854775808 (long) **overflow** | 9.223372036854776E18 (double) |
| Byte.MIN_VALUE − (1).byteValue() | −129 (int) | −129 (short) |
| Byte.MIN_VALUE + (1).byteValue() | −127 (int) result is always int | −127 (byte) |
| Byte.MAX_VALUE − (1).byteValue() | 126 (int) result is always int | 126 (byte) |
| Byte.MAX_VALUE + (1).byteValue() | 128 (int) | 128 (short) |
| JXN: type conversion for division with non integer result preserves precision: |
| 12/4 | 3 (int) | 3 (int) |
| 15/4 | 3 (int) *fractional part is truncated* | 3.75 (double) precision preserved |
| JXN: x^y for pow(x,y): |
| 2^30 | 1.073741824E9 (double) | 1073741824 (int) |
| 2^31 | 2.147483648E9 (double) | 2147483648 (long) switch to long |
| 2^62 | 4.6116860184273879E18 (double) | 4611686018427387904 (long) |
| 2^63 | 9.223372036854776E18 (double) | 9.223372036854776E18 (double) |
| JXN: byte arithmetic ⇒ byte result (analog: short arithmetic ⇒ short result): |
| (7).byteValue() + (5).byteValue() | 12 (int) java: result is always int | 12 (byte) |
| (7).byteValue() − (5).byteValue() | 2 (int) | 2 (byte) |
| (7).byteValue() * (5).byteValue() | 35 (int) | 35 (byte) |
| (15).byteValue() / (5).byteValue() | 3 (int) | 3 (byte) |
| (7).byteValue() / (5).byteValue() | 1 (int) *fractional part is truncated* | 1.4 (double) precision preserved |
| (7).byteValue() % (5).byteValue() | 2 (int) | 2 (byte) |
| (7).byteValue() ^ (5).byteValue() | 16807.0 (double) | 16807 (int) result is int, long or double |