e_scalb.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. * __ieee754_scalb(x, 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. #ifdef _SCALB_INT
  19. double attribute_hidden __ieee754_scalb(double x, int fn)
  20. #else
  21. double attribute_hidden __ieee754_scalb(double x, double fn)
  22. #endif
  23. {
  24. #ifdef _SCALB_INT
  25. return scalbn(x,fn);
  26. #else
  27. if (isnan(x)||isnan(fn)) return x*fn;
  28. if (!isfinite(fn)) {
  29. if(fn>0.0) return x*fn;
  30. else return x/(-fn);
  31. }
  32. if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
  33. if ( fn > 65000.0) return scalbn(x, 65000);
  34. if (-fn > 65000.0) return scalbn(x,-65000);
  35. return scalbn(x,(int)fn);
  36. #endif
  37. }