e_scalb.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* @(#)e_scalb.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. #include "cdefs-compat.h"
  13. //__FBSDID("$FreeBSD: src/lib/msun/src/e_scalb.c,v 1.13 2008/02/22 02:30:35 das Exp $");
  14. /*
  15. * __ieee754_scalb(x, fn) is provide for
  16. * passing various standard test suite. One
  17. * should use scalbn() instead.
  18. */
  19. #include "openlibm.h"
  20. #include "math_private.h"
  21. #ifdef _SCALB_INT
  22. DLLEXPORT double
  23. __ieee754_scalb(double x, int fn)
  24. #else
  25. DLLEXPORT double
  26. __ieee754_scalb(double x, double fn)
  27. #endif
  28. {
  29. #ifdef _SCALB_INT
  30. return scalbn(x,fn);
  31. #else
  32. if (isnan(x)||isnan(fn)) return x*fn;
  33. if (!finite(fn)) {
  34. if(fn>0.0) return x*fn;
  35. else return x/(-fn);
  36. }
  37. if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
  38. if ( fn > 65000.0) return scalbn(x, 65000);
  39. if (-fn > 65000.0) return scalbn(x,-65000);
  40. return scalbn(x,(int)fn);
  41. #endif
  42. }