home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 608b.lha / icalc_v1.1a / src / math.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-30  |  650 b   |  33 lines

  1. /*
  2. *    icalc - complex-expression parser
  3. *
  4. *    Standard (real) math routines with domain/range checking, for 
  5. *    complex-number expression parser (almost redundant now...).
  6. *
  7. *    (C) Martin W Scott, 1991.
  8. */
  9. #include <math.h>
  10. #include <errno.h>
  11. #include "complex.h"
  12. extern    int    errno;
  13.  
  14. double Log(x)
  15.     double x;
  16. {
  17.     return errcheck(log(x), "log");
  18. }
  19.  
  20. double errcheck(d, s)    /* check result of library call */
  21.     double d;    /* doesn't seem to work when using IEEE math libs */
  22.     char *s;
  23. {
  24.     if (errno == EDOM) {
  25.         errno = 0;
  26.         execerror(s, "argument out of domain");
  27.     } else if (errno == ERANGE) {
  28.         errno = 0;
  29.         execerror(s, "result out of range");
  30.     }
  31.     return d;
  32. }
  33.