2 /* @(#)s_ldexp.c 5.1 93/09/24 */
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
11 * ====================================================
16 <<ldexp>>, <<ldexpf>>---load exponent
25 double ldexp(double <[val]>, int <[exp]>);
26 float ldexpf(float <[val]>, int <[exp]>);
31 double ldexp(<[val]>, <[exp]>)
35 float ldexpf(<[val]>, <[exp]>)
41 <<ldexp>> calculates the value
43 <[val]> times 2 to the power <[exp]>.
48 <<ldexpf>> is identical, save that it takes and returns <<float>>
49 rather than <<double>> values.
52 <<ldexp>> returns the calculated value.
54 Underflow and overflow both set <<errno>> to <<ERANGE>>.
55 On underflow, <<ldexp>> and <<ldexpf>> return 0.0.
56 On overflow, <<ldexp>> returns plus or minus <<HUGE_VAL>>.
59 <<ldexp>> is ANSI, <<ldexpf>> is an extension.
66 #ifndef _DOUBLE_IS_32BITS
69 double ldexp(double value
, int exp
)
71 double ldexp(value
, exp
)
72 double value
; int exp
;
75 if(!finite(value
)||value
==0.0) return value
;
76 value
= scalbn(value
,exp
);
77 if(!finite(value
)||value
==0.0) errno
= ERANGE
;
81 #endif /* _DOUBLE_IS_32BITS */