w_pow.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* @(#)w_pow.c 5.2 93/10/01 */
  2. /*
  3. * ====================================================
  4. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  5. *
  6. * Developed at SunPro, a Sun Microsystems, Inc. business.
  7. * Permission to use, copy, modify, and distribute this
  8. * software is freely granted, provided that this notice
  9. * is preserved.
  10. * ====================================================
  11. */
  12. /*
  13. * wrapper pow(x,y) return x**y
  14. */
  15. #include "math.h"
  16. #include "math_private.h"
  17. #ifdef __STDC__
  18. double pow(double x, double y) /* wrapper pow */
  19. #else
  20. double pow(x,y) /* wrapper pow */
  21. double x,y;
  22. #endif
  23. {
  24. #ifdef _IEEE_LIBM
  25. return __ieee754_pow(x,y);
  26. #else
  27. double z;
  28. z=__ieee754_pow(x,y);
  29. if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
  30. if(isnan(x)) {
  31. if(y==0.0)
  32. return __kernel_standard(x,y,42); /* pow(NaN,0.0) */
  33. else
  34. return z;
  35. }
  36. if(x==0.0){
  37. if(y==0.0)
  38. return __kernel_standard(x,y,20); /* pow(0.0,0.0) */
  39. if(finite(y)&&y<0.0)
  40. return __kernel_standard(x,y,23); /* pow(0.0,negative) */
  41. return z;
  42. }
  43. if(!finite(z)) {
  44. if(finite(x)&&finite(y)) {
  45. if(isnan(z))
  46. return __kernel_standard(x,y,24); /* pow neg**non-int */
  47. else
  48. return __kernel_standard(x,y,21); /* pow overflow */
  49. }
  50. }
  51. if(z==0.0&&finite(x)&&finite(y))
  52. return __kernel_standard(x,y,22); /* pow underflow */
  53. return z;
  54. #endif
  55. }
  56. libm_hidden_def(pow)