home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / source / _matherr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-24  |  1.2 KB  |  42 lines

  1. /***
  2. *
  3. * name             __matherr -- math error handler
  4. *
  5. * synopsis         action = __matherr(x);
  6. *                  int action;             non-zero if new value supplied
  7. *                  struct __exception *x;
  8. *
  9. * description      This function is called by functions in the math library
  10. *                  when an error occurs.  The exception vector contains
  11. *                  information about the function that encountered the
  12. *                  error, including the error type, function name, first
  13. *                  two arguments, and proposed default value.
  14. *
  15. *                  Normally, matherr translates the error type into a code
  16. *                  that is placed into "errno".  Then, matherr signals
  17. *                  the caller to simply use the proposed default.  Other
  18. *                  actions are possible if the user replaces or enhances
  19. *                  this function with application-specific code.
  20. ***/
  21.  
  22. #include <errno.h>
  23. #include <math.h>
  24.  
  25.  
  26.  
  27. __matherr(x)
  28.     struct __exception *x;
  29. {
  30.     switch(x->type) {
  31.         case DOMAIN:
  32.         case SING:
  33.             errno = EDOM;
  34.             break;
  35.  
  36.         default:
  37.             errno = ERANGE;
  38.     }
  39.  
  40.     return(0);
  41. }
  42.