w_exp.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* @(#)w_exp.c 1.4 04/04/22 */
  2. /*
  3. * ====================================================
  4. * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
  5. *
  6. * Permission to use, copy, modify, and distribute this
  7. * software is freely granted, provided that this notice
  8. * is preserved.
  9. * ====================================================
  10. */
  11. /*
  12. * wrapper exp(x)
  13. */
  14. #include "fdlibm.h"
  15. #ifdef __STDC__
  16. static const double
  17. #else
  18. static double
  19. #endif
  20. o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
  21. u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
  22. #ifdef __STDC__
  23. double exp(double x) /* wrapper exp */
  24. #else
  25. double exp(x) /* wrapper exp */
  26. double x;
  27. #endif
  28. {
  29. #ifdef _IEEE_LIBM
  30. return __ieee754_exp(x);
  31. #else
  32. double z;
  33. z = __ieee754_exp(x);
  34. if(_LIB_VERSION == _IEEE_) return z;
  35. if(finite(x)) {
  36. if(x>o_threshold)
  37. return __kernel_standard(x,x,6); /* exp overflow */
  38. else if(x<u_threshold)
  39. return __kernel_standard(x,x,7); /* exp underflow */
  40. }
  41. return z;
  42. #endif
  43. }