4 ms·
> an ISA that doesn't have an integer type with wrapping semantics (e.g. the JVM.) This is incorrect: the JVM has fully well-defined modulo arithmetic: http:/
by the_why_of_y 12y ago
> an ISA that doesn't have an integer type with wrapping semantics (e.g. the JVM.)
This is incorrect: the JVM has fully well-defined modulo arithmetic:
http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.iadd http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.htm...
"The result is the 32 low-order bits of the true mathematical result in a sufficiently wide two's-complement format, represented as a value of type int. If overflow occurs, then the sign of the result may not be the same as the sign of the mathematical sum of the two values.
Despite the fact that overflow may occur, execution of an iadd instruction never throws a run-time exception."
With this definition the JVM doesn't need distinct instructions for unsigned arithmetic since they're identical to signed arithmetic in two's complement (with some exceptions like shifting for which there are both ishr / iushr instructions).