w_scalb.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 scalb(double x, double fn) is provide for
  13. * passing various standard test suite. One
  14. * should use scalbn() instead.
  15. */
  16. #include <math.h>
  17. #include "math_private.h"
  18. #include <errno.h>
  19. #ifdef _SCALB_INT
  20. double scalb(double x, int fn) /* wrapper scalb */
  21. #else
  22. double scalb(double x, double fn) /* wrapper scalb */
  23. #endif
  24. {
  25. #ifdef _IEEE_LIBM
  26. return __ieee754_scalb(x,fn);
  27. #else
  28. double z;
  29. z = __ieee754_scalb(x,fn);
  30. if(_LIB_VERSION == _IEEE_) return z;
  31. if(!(isfinite(z)||isnan(z))&&isfinite(x)) {
  32. return __kernel_standard(x,(double)fn,32); /* scalb overflow */
  33. }
  34. if(z==0.0&&z!=x) {
  35. return __kernel_standard(x,(double)fn,33); /* scalb underflow */
  36. }
  37. #ifndef _SCALB_INT
  38. if(!isfinite(fn)) errno = ERANGE;
  39. #endif
  40. return z;
  41. #endif
  42. }