fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / math / s_ldexp.c
blobe5d45633da9cdbbb5d31574b6ff5d3ed1f153fef
2 /* @(#)s_ldexp.c 5.1 93/09/24 */
3 /*
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
10 * is preserved.
11 * ====================================================
15 FUNCTION
16 <<ldexp>>, <<ldexpf>>---load exponent
18 INDEX
19 ldexp
20 INDEX
21 ldexpf
23 ANSI_SYNOPSIS
24 #include <math.h>
25 double ldexp(double <[val]>, int <[exp]>);
26 float ldexpf(float <[val]>, int <[exp]>);
28 TRAD_SYNOPSIS
29 #include <math.h>
31 double ldexp(<[val]>, <[exp]>)
32 double <[val]>;
33 int <[exp]>;
35 float ldexpf(<[val]>, <[exp]>)
36 float <[val]>;
37 int <[exp]>;
40 DESCRIPTION
41 <<ldexp>> calculates the value
42 @ifnottex
43 <[val]> times 2 to the power <[exp]>.
44 @end ifnottex
45 @tex
46 $val\times 2^{exp}$.
47 @end tex
48 <<ldexpf>> is identical, save that it takes and returns <<float>>
49 rather than <<double>> values.
51 RETURNS
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>>.
58 PORTABILITY
59 <<ldexp>> is ANSI, <<ldexpf>> is an extension.
61 */
63 #include "fdlibm.h"
64 #include <errno.h>
66 #ifndef _DOUBLE_IS_32BITS
68 #ifdef __STDC__
69 double ldexp(double value, int exp)
70 #else
71 double ldexp(value, exp)
72 double value; int exp;
73 #endif
75 if(!finite(value)||value==0.0) return value;
76 value = scalbn(value,exp);
77 if(!finite(value)||value==0.0) errno = ERANGE;
78 return value;
81 #endif /* _DOUBLE_IS_32BITS */