e_scalb.c 905 B

123456789101112131415161718192021222324252627282930313233
  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 provided for
  13. * passing various standard test suites.
  14. * One should use scalbn() instead.
  15. */
  16. #include "math.h"
  17. #include "math_private.h"
  18. #include <errno.h>
  19. double __ieee754_scalb(double x, double fn)
  20. {
  21. if (isnan(x)||isnan(fn)) return x*fn;
  22. if (!isfinite(fn)) {
  23. if(fn>0.0) return x*fn;
  24. else return x/(-fn);
  25. }
  26. if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
  27. if ( fn > 65000.0) return scalbn(x, 65000);
  28. if (-fn > 65000.0) return scalbn(x,-65000);
  29. return scalbn(x,(int)fn);
  30. }