matherr

Invoked each time an error is detected by functions in the math library.

Library:LibC
Classification:Other
Service:Math

Syntax

  #include <math.h> 
   
  int matherr (
     __FP_EXCEPTION   *err_info);
  

Parameters

err_info

(IN) Points to the structure that contains information about the detected error. See exception.

Return Values

For an unresolved error, returns 0 and sets errno. If you replace matherr with a customized function, your function should return 0 to indicate an error message. Otherwise, it should return a nonzero value.

Remarks

The matherr function is invoked each time an error is detected by functions in the math library. The default matherr supplied in the library returns zero, which causes an error message to be displayed upon stderr and errno to be set with an appropriate error value. An alternative version of this function can be provided, so that mathematical errors are handled by an application.

By calling matherr_handler, you can provide a developer-written version of matherr to take any appropriate action when an error is detected. When zero is returned, an error message is printed upon stderr and errno is set as was the case with the default function. When a nonzero value is returned, no message is printed and errno is not changed. The value err_info -> retval is used as the return value for the function in which the error was detected.

See Also

matherr_handler