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 10 /* sf_ldexp.c -- float version of s_ldexp.c. 11 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 12 */ 13 14 /* 15 * ==================================================== 16 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 17 * 18 * Developed at SunPro, a Sun Microsystems, Inc. business. 19 * Permission to use, copy, modify, and distribute this 20 * software is freely granted, provided that this notice 21 * is preserved. 22 * ==================================================== 23 */ 24 25 #include "fdlibm.h" 26 27 #ifdef __STDC__ ldexpf(float value,int exp)28 float ldexpf(float value, int exp) 29 #else 30 float ldexpf(value, exp) 31 float value; int exp; 32 #endif 33 { 34 if(!isfinite(value)||value==(float)0.0) return value; 35 value = scalbnf(value,exp); 36 //if(!finitef(value)||value==(float)0.0) errno = ERANGE; 37 return value; 38 } 39 40 #ifdef _DOUBLE_IS_32BITS 41 42 #ifdef __STDC__ ldexp(double value,int exp)43 double ldexp(double value, int exp) 44 #else 45 double ldexp(value, exp) 46 double value; int exp; 47 #endif 48 { 49 return (double) ldexpf((float) value, exp); 50 } 51 52 #endif /* defined(_DOUBLE_IS_32BITS) */ 53