Why was SIGFPE used for integer arithmetic exceptions?
Asked Answered
T

1

8

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?

Trahurn answered 8/2, 2020 at 14:28 Comment(2)
I was looking at this particular answer and its comment: https://mcmap.net/q/20602/-why-does-integer-division-by-zero-result-in-a-floating-point-exceptionPrendergast
@root: That seems plausible, and I might accept it if somebody enters such an answer here, if nothing more definitive is submitted. I have a PDP-11 handbook here, and the index does show exceptions only for the floating-point processor.Trahurn
E
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.

Emulate answered 11/2, 2020 at 13:38 Comment(1)
This isn't bad speculation but you should be aware that the x86 is about ten years too new to have affected which signals are used for what. If there's an answer to be had to this question, it probably lies in the behavior of the 1970s minicomputers that UNIX was originally developed for.Nuristan

© 2022 - 2024 — McMap. All rights reserved.