s_expm1f.c (176082) | s_expm1f.c (176132) |
---|---|
1/* s_expm1f.c -- float version of s_expm1.c. 2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 */ 4 5/* 6 * ==================================================== 7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 * 9 * Developed at SunPro, a Sun Microsystems, Inc. business. 10 * Permission to use, copy, modify, and distribute this 11 * software is freely granted, provided that this notice 12 * is preserved. 13 * ==================================================== 14 */ 15 16#include <sys/cdefs.h> | 1/* s_expm1f.c -- float version of s_expm1.c. 2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 */ 4 5/* 6 * ==================================================== 7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8 * 9 * Developed at SunPro, a Sun Microsystems, Inc. business. 10 * Permission to use, copy, modify, and distribute this 11 * software is freely granted, provided that this notice 12 * is preserved. 13 * ==================================================== 14 */ 15 16#include <sys/cdefs.h> |
17__FBSDID("$FreeBSD: head/lib/msun/src/s_expm1f.c 176082 2008-02-07 09:42:19Z bde $"); | 17__FBSDID("$FreeBSD: head/lib/msun/src/s_expm1f.c 176132 2008-02-09 12:53:15Z bde $"); |
18 19#include "math.h" 20#include "math_private.h" 21 22static const float 23one = 1.0, 24huge = 1.0e+30, 25tiny = 1.0e-30, 26o_threshold = 8.8721679688e+01,/* 0x42b17180 */ 27ln2_hi = 6.9313812256e-01,/* 0x3f317180 */ 28ln2_lo = 9.0580006145e-06,/* 0x3717f7d1 */ 29invln2 = 1.4426950216e+00,/* 0x3fb8aa3b */ | 18 19#include "math.h" 20#include "math_private.h" 21 22static const float 23one = 1.0, 24huge = 1.0e+30, 25tiny = 1.0e-30, 26o_threshold = 8.8721679688e+01,/* 0x42b17180 */ 27ln2_hi = 6.9313812256e-01,/* 0x3f317180 */ 28ln2_lo = 9.0580006145e-06,/* 0x3717f7d1 */ 29invln2 = 1.4426950216e+00,/* 0x3fb8aa3b */ |
30 /* scaled coefficients related to expm1 */ 31Q1 = -3.3333335072e-02, /* 0xbd088889 */ 32Q2 = 1.5873016091e-03, /* 0x3ad00d01 */ 33Q3 = -7.9365076090e-05, /* 0xb8a670cd */ 34Q4 = 4.0082177293e-06, /* 0x36867e54 */ 35Q5 = -2.0109921195e-07; /* 0xb457edbb */ | 30/* 31 * Domain [-0.34568, 0.34568], range ~[-6.694e-10, 6.696e-10]: 32 * |6 / x * (1 + 2 * (1 / (exp(x) - 1) - 1 / x)) - q(x)| < 2**-30.04 33 * Scaled coefficients: Qn_here = 2**n * Qn_for_q (see s_expm1.c): 34 */ 35Q1 = -3.3333212137e-2, /* -0x888868.0p-28 */ 36Q2 = 1.5807170421e-3; /* 0xcf3010.0p-33 */ |
36 37float 38expm1f(float x) 39{ 40 float y,hi,lo,c,t,e,hxs,hfx,r1,twopk; 41 int32_t k,xsb; 42 u_int32_t hx; 43 --- 37 unchanged lines hidden (view full) --- 81 t = huge+x; /* return x with inexact flags when x!=0 */ 82 return x - (t-(huge+x)); 83 } 84 else k = 0; 85 86 /* x is now in primary range */ 87 hfx = (float)0.5*x; 88 hxs = x*hfx; | 37 38float 39expm1f(float x) 40{ 41 float y,hi,lo,c,t,e,hxs,hfx,r1,twopk; 42 int32_t k,xsb; 43 u_int32_t hx; 44 --- 37 unchanged lines hidden (view full) --- 82 t = huge+x; /* return x with inexact flags when x!=0 */ 83 return x - (t-(huge+x)); 84 } 85 else k = 0; 86 87 /* x is now in primary range */ 88 hfx = (float)0.5*x; 89 hxs = x*hfx; |
89 r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5)))); | 90 r1 = one+hxs*(Q1+hxs*Q2); |
90 t = (float)3.0-r1*hfx; 91 e = hxs*((r1-t)/((float)6.0 - x*t)); 92 if(k==0) return x - (x*e-hxs); /* c is 0 */ 93 else { 94 SET_FLOAT_WORD(twopk,0x3f800000+(k<<23)); /* 2^k */ 95 e = (x*(e-c)-c); 96 e -= hxs; 97 if(k== -1) return (float)0.5*(x-e)-(float)0.5; --- 23 unchanged lines hidden --- | 91 t = (float)3.0-r1*hfx; 92 e = hxs*((r1-t)/((float)6.0 - x*t)); 93 if(k==0) return x - (x*e-hxs); /* c is 0 */ 94 else { 95 SET_FLOAT_WORD(twopk,0x3f800000+(k<<23)); /* 2^k */ 96 e = (x*(e-c)-c); 97 e -= hxs; 98 if(k== -1) return (float)0.5*(x-e)-(float)0.5; --- 23 unchanged lines hidden --- |