home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_07 / 9n07014a < prev    next >
Text File  |  1991-05-23  |  336b  |  22 lines

  1.  
  2. /* fabs function */
  3. #include "xmath.h"
  4.  
  5. double (fabs)(double x)
  6.     {    /* compute fabs */
  7.     switch (_Dtest(&x))
  8.         {    /* test for special codes */
  9.     case NAN:
  10.         errno = EDOM;
  11.         return (x);
  12.     case INF:
  13.         errno = ERANGE;
  14.         return (_Inf._D);
  15.     case 0:
  16.         return (0.0);
  17.     default:    /* finite */
  18.         return (x  0.0 ? -x : x);
  19.         }
  20.     }
  21.  
  22.