Why was SIGFPE used for integer arithmetic exceptions?

倖福魔咒の 提交于 2020-02-21 10:57:45

问题


Why was SIGFPE used for integer arithmetic exceptions, such as division by zero, instead of creating a separate signal for integer arithmetic exceptions or naming the signal in the first place for arithmetic exceptions generally?


回答1:


IEEE Std 1003.1 Standard defines SIGFPE as:

Erroneous arithmetic operation.

And doesn't really mention floating point operations. Reasoning behind this is not clearly stated, but here's my take on it.

x86 FPU can operate on both integer and floating point data at the same time with instructions such as FIDIV, thus it would be unclear whether dividing floating poitn data by integer zero would generate a floating or and integer point exception.

Additionally, up to 80486 (which was released the same year as the ISO/ANSI C standard) x86 CPUs did not have floating point capabilities at all, floating point co-processor was a separate chip. Software floating point emulation could be used in place of the chip, but that used CPU's built in ALU (integer arithmetic-logical unit) which would throw integer exceptions.



来源:https://stackoverflow.com/questions/60127747/why-was-sigfpe-used-for-integer-arithmetic-exceptions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!