w_pow.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * ====================================================
  3. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  4. *
  5. * Developed at SunPro, a Sun Microsystems, Inc. business.
  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 pow(x,y) return x**y
  13. */
  14. #include "math.h"
  15. #include "math_private.h"
  16. double pow(double x, double y) /* wrapper pow */
  17. {
  18. #ifdef _IEEE_LIBM
  19. return __ieee754_pow(x,y);
  20. #else
  21. double z;
  22. z=__ieee754_pow(x,y);
  23. if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
  24. if(isnan(x)) {
  25. if(y==0.0)
  26. return __kernel_standard(x,y,42); /* pow(NaN,0.0) */
  27. else
  28. return z;
  29. }
  30. if(x==0.0){
  31. if(y==0.0)
  32. return __kernel_standard(x,y,20); /* pow(0.0,0.0) */
  33. if(isfinite(y)&&y<0.0)
  34. return __kernel_standard(x,y,23); /* pow(0.0,negative) */
  35. return z;
  36. }
  37. if(!isfinite(z)) {
  38. if(isfinite(x)&&isfinite(y)) {
  39. if(isnan(z))
  40. return __kernel_standard(x,y,24); /* pow neg**non-int */
  41. else
  42. return __kernel_standard(x,y,21); /* pow overflow */
  43. }
  44. }
  45. if(z==0.0&&isfinite(x)&&isfinite(y))
  46. return __kernel_standard(x,y,22); /* pow underflow */
  47. return z;
  48. #endif
  49. }
  50. libm_hidden_def(pow)