2 ms·
> At that point overflow has already occured, so your program state is now nonsense, and you might as well just let it crash unhandled. The trick is to check
by Findecanor 3y ago
> At that point overflow has already occured, so your program state is now nonsense, and you might as well just let it crash unhandled.
The trick is to check and clear the flag before any instruction that would have a side-effect, that depends on the arithmetic result.
IEEE 754-compliant floating point units have a similar behaviour with NaN that is a bit more versatile: an arithmetic instruction results in NaN if any operand is NaN, but an instruction with side-effect (compare, convert or store) will raise an exception if given a NaN.