Subject: Re: SIGFPE?
To: Richard Rauch <rauch@eecs.ukans.edu>
From: Robert Elz <kre@munnari.OZ.AU>
List: netbsd-help
Date: 05/02/2001 17:05:52
    Date:        Tue, 1 May 2001 23:53:14 -0500 (CDT)
    From:        Richard Rauch <rauch@eecs.ukans.edu>
    Message-ID:  <Pine.BSF.4.21.0105012311150.30064-100000@tesla.eecs.ukans.edu>

  | (The following definitely pertains to port-i386.  I am running 1.5,
  | proper.  I have no means to test it on other ports.  I assume that this is
  | generic to all ports, however, and so I'm posting to this list rather than
  | to port-i386.)

No, it is generic to ports with ieee floating point support, but not to
others.

ieee float specifies that (floating) x/0 is not to raise an exception,
but instead generate "infinity" (for which there is a specific bit
pattern defined).

Thus, you get no SIGFPE from the division.   You might get one later
from attempting to operate upon the result (perhaps - depends upon the
operation).

Integer divide by 0 generates SIGFPE as it isn't subject to the ieee
floating point spec, and never could be - there's no bit pattern that
can be used to represent infinity in an integer.

  | So, I am bothered by:
  |  (a) No detection for overflow.

It is detected, just recorded in a different way.   The theory is that
if you care, your code can test for this result before you need the result.
If you don't, and use the result in an inconsistent way, then the signal
is generated.   Otherwise, you either never use the result (in which case
it harldy matters) or you only use it in a way where remaining stuck at
infinity is reasonable (if you print it, you should see some representation
of infinity instead of a number).

  |  (b) Inasmuch as SIGFPE seems to be used, it is applied to integer
  |      arithmetic, rather than to floating point arithmetic.

It is used for all arithmetic exceptions.   The name comes form the (kind of
weird) PDP-11 architecture where integer divisions were done by the floating
point unit, and hence generated a floating point exception on integer divide
by 0.

kre