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.

64 lines
1.3 KiB

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