w_pow.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. libm_hidden_proto(pow)
  18. #ifdef __STDC__
  19. double pow(double x, double y) /* wrapper pow */
  20. #else
  21. double pow(x,y) /* wrapper pow */
  22. double x,y;
  23. #endif
  24. {
  25. #ifdef _IEEE_LIBM
  26. return __ieee754_pow(x,y);
  27. #else
  28. double z;
  29. z=__ieee754_pow(x,y);
  30. if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
  31. if(isnan(x)) {
  32. if(y==0.0)
  33. return __kernel_standard(x,y,42); /* pow(NaN,0.0) */
  34. else
  35. return z;
  36. }
  37. if(x==0.0){
  38. if(y==0.0)
  39. return __kernel_standard(x,y,20); /* pow(0.0,0.0) */
  40. if(finite(y)&&y<0.0)
  41. return __kernel_standard(x,y,23); /* pow(0.0,negative) */
  42. return z;
  43. }
  44. if(!finite(z)) {
  45. if(finite(x)&&finite(y)) {
  46. if(isnan(z))
  47. return __kernel_standard(x,y,24); /* pow neg**non-int */
  48. else
  49. return __kernel_standard(x,y,21); /* pow overflow */
  50. }
  51. }
  52. if(z==0.0&&finite(x)&&finite(y))
  53. return __kernel_standard(x,y,22); /* pow underflow */
  54. return z;
  55. #endif
  56. }
  57. libm_hidden_def(pow)