HP C/iX Library Reference Manual (30026-90004)

Chapter 5 247
HP C/iX Library Function Descriptions
matherr
matherr
The matherr function is a user-written call-back routine invoked by many functions in the
math library when errors are detected.
Syntax
#include <math.h>
int matherr (
x
)
struct exception *
x
;
Parameters
x
A pointer to the exception structure defined in the <math.h> header file.
Return Values
x A user-defined integer value.
Description
Users override the default math library error handler by defining a function named
matherr in their programs. This user-written matherr function must follow the syntax
described above.
When an error occurs, a pointer to the exception structure
x
is passed to your matherr
function.
The structure is defined as follows:
struct exception {
int type;
char *name;
double arg1, arg2, retval;
};
The element type is an integer describing the type of error that occurred, from the
following list of constants defined in the header file:
DOMAIN argument domain error
SING argument singularity
OVERFLOW overflow range error
UNDERFLOW underflow range error
TLOSS total loss of significance
PLOSS partial loss of significance
The element name points to a string containing the name of the function that caused the
error. The variables arg1 and arg2 are the arguments you use to invoke the function.
retval is set to the default value that is returned by the function unless your matherr sets