home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / xcosh.c < prev    next >
C/C++ Source or Header  |  1998-06-16  |  821b  |  43 lines

  1. /* _Cosh function */
  2. #include "wctype.h"
  3. #include "xmath.h"
  4. _STD_BEGIN
  5.  
  6. _CRTIMP2 double __cdecl _Cosh(double x, double y)
  7.     {    /* compute y * cosh(x), |y| <= 1 */
  8.     switch (_Dtest(&x))
  9.         {    /* test for special codes */
  10.     case NAN:
  11.         errno = EDOM;
  12.         return (x);
  13.     case INF:
  14.         if (y == 0)
  15.             return (0);
  16.         errno = ERANGE;
  17.         return (_Inf._D);
  18.     case 0:
  19.         return (y);
  20.     default:    /* finite */
  21.         if (x < 0)
  22.             x = -x;
  23.         if (x < _Xbig)
  24.             {    /* worth adding in exp(-x) */
  25.             _Exp(&x, 1, -1);
  26.             return (y * (x + 0.25 / x));
  27.             }
  28.         if (0 <= _Exp(&x, y, -1))
  29.             errno = ERANGE;    /* x large */
  30.         return (x);
  31.         }
  32.     }
  33. _STD_END
  34.  
  35. /*
  36.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  37.  * Consult your license regarding permissions and restrictions.
  38.  */
  39.  
  40. /*
  41. 941029 pjp: added _STD machinery
  42.  */
  43.