2 /* @(#)z_ldexp.c 1.0 98/08/13 */
6 <<ldexp>>, <<ldexpf>>---load exponent
15 double ldexp(double <[val]>, int <[exp]>);
16 float ldexpf(float <[val]>, int <[exp]>);
19 <<ldexp>> calculates the value
21 <[val]> times 2 to the power <[exp]>.
26 <<ldexpf>> is identical, save that it takes and returns <<float>>
27 rather than <<double>> values.
30 <<ldexp>> returns the calculated value.
32 Underflow and overflow both set <<errno>> to <<ERANGE>>.
33 On underflow, <<ldexp>> and <<ldexpf>> return 0.0.
34 On overflow, <<ldexp>> returns plus or minus <<HUGE_VAL>>.
37 <<ldexp>> is ANSI. <<ldexpf>> is an extension.
41 /******************************************************************
45 * d - a floating point value
46 * e - an exponent value
49 * A floating point value f such that f = d * 2 ^ e.
52 * This function creates a floating point number f such that
55 *****************************************************************/
61 #ifndef _DOUBLE_IS_32BITS
63 #define DOUBLE_EXP_OFFS 1023
72 GET_HIGH_WORD (hd
, d
);
74 /* Check for special values and then scale d by e. */
89 exp
= (hd
& 0x7ff00000) >> 20;
92 if (exp
> DBL_MAX_EXP
+ DOUBLE_EXP_OFFS
)
97 else if (exp
< DBL_MIN_EXP
+ DOUBLE_EXP_OFFS
)
106 SET_HIGH_WORD (d
, hd
);
113 #endif /* _DOUBLE_IS_32BITS */