w_pow.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* @(#)w_pow.c 1.3 95/01/18 */
  2. /*
  3. * ====================================================
  4. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  5. *
  6. * Developed at SunSoft, 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 "fdlibm.h"
  16. #ifdef __STDC__
  17. double pow(double x, double y) /* wrapper pow */
  18. #else
  19. double pow(x,y) /* wrapper pow */
  20. double x,y;
  21. #endif
  22. {
  23. #ifdef _IEEE_LIBM
  24. return __ieee754_pow(x,y);
  25. #else
  26. double z;
  27. z=__ieee754_pow(x,y);
  28. if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
  29. if(isnan(x)) {
  30. if(y==0.0)
  31. return __kernel_standard(x,y,42); /* pow(NaN,0.0) */
  32. else
  33. return z;
  34. }
  35. if(x==0.0){
  36. if(y==0.0)
  37. return __kernel_standard(x,y,20); /* pow(0.0,0.0) */
  38. if(finite(y)&&y<0.0)
  39. return __kernel_standard(x,y,23); /* pow(0.0,negative) */
  40. return z;
  41. }
  42. if(!finite(z)) {
  43. if(finite(x)&&finite(y)) {
  44. if(isnan(z))
  45. return __kernel_standard(x,y,24); /* pow neg**non-int */
  46. else
  47. return __kernel_standard(x,y,21); /* pow overflow */
  48. }
  49. }
  50. if(z==0.0&&finite(x)&&finite(y))
  51. return __kernel_standard(x,y,22); /* pow underflow */
  52. return z;
  53. #endif
  54. }