sf_ldexp.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * This file is part of the MicroPython project, http://micropython.org/
  3. *
  4. * These math functions are taken from newlib-nano-2, the newlib/libm/math
  5. * directory, available from https://github.com/32bitmicro/newlib-nano-2.
  6. *
  7. * Appropriate copyright headers are reproduced below.
  8. */
  9. /* sf_ldexp.c -- float version of s_ldexp.c.
  10. * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
  11. */
  12. /*
  13. * ====================================================
  14. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  15. *
  16. * Developed at SunPro, a Sun Microsystems, Inc. business.
  17. * Permission to use, copy, modify, and distribute this
  18. * software is freely granted, provided that this notice
  19. * is preserved.
  20. * ====================================================
  21. */
  22. #include "fdlibm.h"
  23. //#include <errno.h>
  24. #ifdef __STDC__
  25. float ldexpf(float value, int exp)
  26. #else
  27. float ldexpf(value, exp)
  28. float value; int exp;
  29. #endif
  30. {
  31. if(!isfinite(value)||value==(float)0.0) return value;
  32. value = scalbnf(value,exp);
  33. //if(!finitef(value)||value==(float)0.0) errno = ERANGE;
  34. return value;
  35. }
  36. #ifdef _DOUBLE_IS_32BITS
  37. #ifdef __STDC__
  38. double ldexp(double value, int exp)
  39. #else
  40. double ldexp(value, exp)
  41. double value; int exp;
  42. #endif
  43. {
  44. return (double) ldexpf((float) value, exp);
  45. }
  46. #endif /* defined(_DOUBLE_IS_32BITS) */