3 * Base 2 exponential function
17 * Returns 2 raised to the x power.
19 * Range reduction is accomplished by separating the argument
20 * into an integer k and fraction f such that
24 * A polynomial approximates 2**x in the basic range [-0.5, 0.5].
30 * arithmetic domain # trials peak rms
31 * IEEE -127,+127 100000 1.7e-7 2.8e-8
34 * See exp.c for comments on error amplification.
39 * message condition value returned
40 * exp underflow x < -MAXL2 0.0
41 * exp overflow x > MAXL2 MAXNUMF
43 * For IEEE arithmetic, MAXL2 = 127.
48 Cephes Math Library Release 2.2: June, 1992
49 Copyright 1984, 1987, 1988, 1992 by Stephen L. Moshier
50 Direct inquiries to 30 Frost Street, Cambridge, MA 02140
56 static char fname[] = {"exp2f"};
59 1.535336188319500E-004,
60 1.339887440266574E-003,
61 9.618437357674640E-003,
62 5.550332471162809E-002,
63 2.402264791363012E-001,
64 6.931472028550421E-001
73 float polevlf(float, float *, int), floorf(float), ldexpf(float, int);
75 float exp2f( float xx )
83 mtherr( fname, OVERFLOW );
89 mtherr( fname, UNDERFLOW );
93 /* The following is necessary because range reduction blows up: */
97 /* separate into integer and fractional parts */
108 /* rational approximation
109 * exp2(x) = 1.0 + xP(x)
111 px = 1.0 + x * polevlf( x, P, 5 );
113 /* scale by power of 2 */
114 px = ldexpf( px, i0 );