Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.3 KiB

  1. /* _FSinh function */
  2. #include "wctype.h"
  3. #include "xmath.h"
  4. _STD_BEGIN
  5. /* coefficients */
  6. #define NP (sizeof (p) / sizeof (p[0]) - 1)
  7. static const float p[] = { /* courtesy Dr. Tim Prince */
  8. 0.00020400F,
  9. 0.00832983F,
  10. 0.16666737F,
  11. 0.99999998F};
  12. _CRTIMP2 float __cdecl _FSinh(float x, float y)
  13. { /* compute y*sinh(x), |y| <= 1 */
  14. switch (_FDtest(&x))
  15. { /* test for special codes */
  16. case NAN:
  17. errno = EDOM;
  18. return (x);
  19. case INF:
  20. if (y == 0)
  21. return (0);
  22. errno = ERANGE;
  23. return (FSIGN(x) ? -_FInf._F : _FInf._F);
  24. case 0:
  25. return (0);
  26. default: /* finite */
  27. { /* compute sinh(finite) */
  28. short neg;
  29. if (x < 0)
  30. x = -x, neg = 1;
  31. else
  32. neg = 0;
  33. if (x < _FRteps._F)
  34. x *= y; /* x tiny */
  35. else if (x < 1)
  36. {
  37. float w = x * x;
  38. x += ((p[0] * w + p[1]) * w + p[2]) * w * x;
  39. x *= y;
  40. }
  41. else if (x < _FXbig)
  42. { /* worth adding in exp(-x) */
  43. _FExp(&x, 1, -1);
  44. x = y * (x - 0.25 / x);
  45. }
  46. else if (0 <= _FExp(&x, y, -1))
  47. errno = ERANGE; /* x large */
  48. return (neg ? -x : x);
  49. }
  50. }
  51. }
  52. _STD_END
  53. /*
  54. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  55. * Consult your license regarding permissions and restrictions.
  56. */
  57. /*
  58. 941029 pjp: added _STD machinery
  59. */