e_scalbf.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* e_scalbf.c -- float version of e_scalb.c.
  2. * Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected].
  3. */
  4. /*
  5. * ====================================================
  6. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  7. *
  8. * Developed at SunPro, a Sun Microsystems, Inc. business.
  9. * Permission to use, copy, modify, and distribute this
  10. * software is freely granted, provided that this notice
  11. * is preserved.
  12. * ====================================================
  13. */
  14. #include "cdefs-compat.h"
  15. //__FBSDID("$FreeBSD: src/lib/msun/src/e_scalbf.c,v 1.13 2008/02/22 02:30:35 das Exp $");
  16. #include "openlibm.h"
  17. #include "math_private.h"
  18. #ifdef _SCALB_INT
  19. DLLEXPORT float
  20. __ieee754_scalbf(float x, int fn)
  21. #else
  22. DLLEXPORT float
  23. __ieee754_scalbf(float x, float fn)
  24. #endif
  25. {
  26. #ifdef _SCALB_INT
  27. return scalbnf(x,fn);
  28. #else
  29. if ((__isnanf)(x)||(__isnanf)(fn)) return x*fn;
  30. if (!finitef(fn)) {
  31. if(fn>(float)0.0) return x*fn;
  32. else return x/(-fn);
  33. }
  34. if (rintf(fn)!=fn) return (fn-fn)/(fn-fn);
  35. if ( fn > (float)65000.0) return scalbnf(x, 65000);
  36. if (-fn > (float)65000.0) return scalbnf(x,-65000);
  37. return scalbnf(x,(int)fn);
  38. #endif
  39. }