5 ms·
Integer divide by zero does NOT raise an exception. From the Spec: We considered raising exceptions on integer divide by zero, with these exceptions causing a
by RNeff 8y ago
Integer divide by zero does NOT raise an exception.
From the Spec:
We considered raising exceptions on integer divide by zero, with these exceptions causing a trap in
most execution environments. However, this would be the only arithmetic trap in the standard
ISA (floating-point exceptions set flags and write default values, but do not cause traps) and
would require language implementors to interact with the execution environment’s trap handlers
for this case. Further, where language standards mandate that a divide-by-zero exception must
cause an immediate control flow change, only a single branch instruction needs to be added to
each divide operation, and this branch instruction can be inserted after the divide and should
normally be very predictably not taken, adding little runtime overhead.
- nine_k 8y agoIs this a genuinely bad decision? The spec makes a good job arguing why it's not.
- majewsky 8y agoThose are arguments in favor of this design choice. What are the arguments against it?
- phaedrus 8y agoThe reasoning given here for some reason reminds me of Parallax's decision not to add interrupts to the Propeller 1 design.
- nickik 8y agoThe main reason that this is not in is that in many embedded application it is simply not needed. The 'J' extension for managed languages will probably add these things.