home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 521.lha / ICalc_v1.0 / src / math.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-10  |  768 b   |  48 lines

  1. /*
  2. *    standard (real) math routines with domain/range checking, for 
  3. *    complex-number expression parser.
  4. *    MWS, March 17, 1991.
  5. */
  6. #include <math.h>
  7. #include <errno.h>
  8. #include "complex.h"
  9. extern    int    errno;
  10.  
  11. double Sqrt(x)
  12.     double x;
  13. {
  14.     return errcheck(sqrt(x), "sqrt");
  15. }
  16.  
  17. double Log(x)
  18.     double x;
  19. {
  20.     return errcheck(log(x), "log");
  21. }
  22.  
  23. double Asin(x)
  24.     double x;
  25. {
  26.     return errcheck(asin(x), "asin");
  27. }
  28.  
  29. double Acos(x)
  30.     double x;
  31. {
  32.     return errcheck(acos(x), "acos");
  33. }
  34.  
  35. double errcheck(d, s)    /* check result of library call */
  36.     double d;    /* doesn't seem to work under Lattice... */
  37.     char *s;
  38. {
  39.     if (errno == EDOM) {
  40.         errno = 0;
  41.         execerror(s, "argument out of domain");
  42.     } else if (errno == ERANGE) {
  43.         errno = 0;
  44.         execerror(s, "result out of range");
  45.     }
  46.     return d;
  47. }
  48.