Re: division by zero mystery



CBFalconer wrote:
Or the FP unit can return +-INF for the division operation, and the
atan routine can recognize that and return the appropriate value.
Not luck, just QOI.

If with a,b we can obviously have 4 different sign states for a,b but
only two after the division. So what quadrant did the angle occur in?
This also matters for +/-INF because we can have {for example}
DBLE_MAX/DBLE_MIN or -DBLE_MAX/-DBLE_MIN which produce the same thing
(+INF) but for which the angle represented should be different.

Trapping is possible for floating point exceptions according to the C
standard:
"H.3.1.2 Traps
1 C is compatible with LIA-1's trap requirements for arithmetic
operations, but not for math library functions (which are not permitted
to generate any externally visible exceptional conditions). An
implementation can provide an alternative of notification through
termination with a ''hard-to-ignore'' message (see LIA-1
subclause 6.1.3).
2 LIA-1 does not require that traps be precise.
3 C does require that SIGFPE be the signal corresponding to arithmetic
exceptions, if there is any signal raised for them.
4 C supports signal handlers for SIGFPE and allows trapping of
arithmetic exceptions. When arithmetic exceptions do trap, C's
signal-handler mechanism allows trap-andterminate (either default
implementation behavior or user replacement for it) or trap-andresume,
at the programmer's option."

.



Relevant Pages

  • Re: [OT] Re: C Object System
    ... Laurent Deniau wrote: ... Are traps exceptions? ... What COS provides is a service which converts automatically registered signals into exceptions. ... I have developed an extension for lcc-win32 to implement DBC, ...
    (comp.lang.c)
  • Re: IO locked error
    ... That traps all IO errors though... ... you dont seem to have them anymore that I know of ... I still want IO errors like file not found and stuff to throw exceptions ... Prev by Date: ...
    (microsoft.public.dotnet.languages.vb)
  • C library errors -> C++ exceptions
    ... Does anyone know of a mechanism whereby C library functions can be made ... IEEE 754 "exceptions" throw C++ exceptions. ... I note that the glibc documentation suggests that "traps" may be ...
    (comp.lang.cpp)