home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / LATTIC_3.LZH / SRC / MATHERR.C < prev    next >
C/C++ Source or Header  |  1990-01-19  |  1KB  |  42 lines

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