1: 2: 3:
4:
5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: #include "math.h"
17: #include "math_private.h"
18:
19: static const float
20: two25 = 3.355443200e+07,
21: twom25 = 2.9802322388e-08,
22: huge = 1.0e+30,
23: tiny = 1.0e-30;
24:
25: float
26: scalbnf(float x, int n)
27: {
28: int32_t k,ix;
29: GET_FLOAT_WORD(ix,x);
30: k = (ix&0x7f800000)>>23;
31: if (k==0) {
32: if ((ix&0x7fffffff)==0) return x;
33: x *= two25;
34: GET_FLOAT_WORD(ix,x);
35: k = ((ix&0x7f800000)>>23) - 25;
36: if (n< -50000) return tiny*x;
37: }
38: if (k==0xff) return x+x;
39: k = k+n;
40: if (k > 0xfe) return huge*copysignf(huge,x);
41: if (k > 0)
42: {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;}
43: if (k <= -25)
44: if (n > 50000)
45: return huge*copysignf(huge,x);
46: else return tiny*copysignf(tiny,x);
47: k += 25;
48: SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23));
49: return x*twom25;
50: }
51:
52: float
53: ldexpf(float x, int n)
54: {
55: return scalbnf(x, n);
56: }