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.

54 lines
1.4 KiB

  1. /* _FExp function */
  2. #include "xmath.h"
  3. _STD_BEGIN
  4. static const float p[] = { /* courtesy Dr. Tim Prince */
  5. 1.0F,
  6. 60.09114349F};
  7. static const float q[] = { /* courtesy Dr. Tim Prince */
  8. 12.01517514F,
  9. 120.18228722F};
  10. static const float c1 = (22713.0F / 32768.0F);
  11. static const float c2 = 1.4286068203094172321214581765680755e-6F;
  12. static const float hugexp = FHUGE_EXP;
  13. static const float invln2 = 1.4426950408889634073599246810018921F;
  14. _CRTIMP2 short __cdecl _FExp(float *px, float y, short eoff)
  15. { /* compute y*e^(*px), (*px) finite, |y| not huge */
  16. if (*px < -hugexp || y == 0.0F)
  17. { /* certain underflow */
  18. *px = 0.0F;
  19. return (0);
  20. }
  21. else if (hugexp < *px)
  22. { /* certain overflow */
  23. *px = _FInf._Float;
  24. return (_INFCODE);
  25. }
  26. else
  27. { /* xexp won't overflow */
  28. float g = *px * invln2;
  29. short xexp = (short)(g + (g < 0.0F ? - 0.5F : + 0.5F));
  30. g = xexp;
  31. g = (float)((*px - g * c1) - g * c2);
  32. if (-_FEps._Float < g && g < _FEps._Float)
  33. *px = y;
  34. else
  35. { /* g*g worth computing */
  36. const float z = g * g;
  37. const float w = q[0] * z + q[1];
  38. g *= z + p[1];
  39. *px = (w + g) / (w - g) * 2.0F * y;
  40. --xexp;
  41. }
  42. return (_FDscale(px, (long)xexp + eoff));
  43. }
  44. }
  45. _STD_END
  46. /*
  47. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  48. * Consult your license regarding permissions and restrictions.
  49. V3.10:0009 */