matherr
---modifiable math error handler#include <math.h> int matherr(struct exception *e);Description
matherr
is called whenever a math library function generates an error.
You can replace matherr
by your own subroutine to customize
error treatment. The customized matherr
must return 0 if
it fails to resolve the error, and non-zero if the error is resolved.
When matherr
returns a nonzero value, no error message is printed
and the value of errno
is not modified. You can accomplish either
or both of these things in your own matherr
using the information
passed in the structure *e
.
This is the exception
structure (defined in `math.h
'):
struct exception { int type; char *name; double arg1, arg2, retval; int err; };
The members of the exception structure have the following meanings:
type
math.h
'.
name
arg1, arg2
retval
err
errno
.
The error types defined in `math.h
' represent possible mathematical
errors as follows:
DOMAIN
log(-1.0)
.
SING
pow(0.0,-2.0)
OVERFLOW
exp(1000.0)
.
UNDERFLOW
exp(-1000.0)
.
TLOSS
sin(10e70)
.
PLOSS
Returns
The library definition for matherr
returns 0
in all cases.
You can change the calling function's result from a customized matherr
by modifying e->retval
, which propagates backs to the caller.
If matherr
returns 0
(indicating that it was not able to resolve
the error) the caller sets errno
to an appropriate value, and prints
an error message.
Portability
matherr
is not ANSI C.