X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fmath%2Fexpm1f.c;h=d9568466c18f620924c3331d3bf40c31470cf783;hp=cfab6975a7dbe4024cb2f3d70b3612bd097d4870;hb=0cbb65479147ecdaa664e88cc2a5a925f3de502f;hpb=b69f695acedd4ce2798ef9ea28d834ceccc789bd diff --git a/src/math/expm1f.c b/src/math/expm1f.c index cfab6975..d9568466 100644 --- a/src/math/expm1f.c +++ b/src/math/expm1f.c @@ -16,7 +16,6 @@ #include "libm.h" static const float -one = 1.0, huge = 1.0e+30, tiny = 1.0e-30, o_threshold = 8.8721679688e+01, /* 0x42b17180 */ @@ -53,8 +52,8 @@ float expm1f(float x) } if (xsb != 0) { /* x < -27*ln2 */ /* raise inexact */ - if (x+tiny < (float)0.0) - return tiny-one; /* return -1 */ + if (x+tiny < 0.0f) + return tiny-1.0f; /* return -1 */ } } @@ -71,7 +70,7 @@ float expm1f(float x) k = -1; } } else { - k = invln2*x+((xsb==0)?(float)0.5:(float)-0.5); + k = invln2*x + (xsb==0 ? 0.5f : -0.5f); t = k; hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ lo = t*ln2_lo; @@ -85,40 +84,40 @@ float expm1f(float x) k = 0; /* x is now in primary range */ - hfx = (float)0.5*x; + hfx = 0.5f*x; hxs = x*hfx; - r1 = one+hxs*(Q1+hxs*Q2); - t = (float)3.0 - r1*hfx; - e = hxs*((r1-t)/((float)6.0 - x*t)); + r1 = 1.0f+hxs*(Q1+hxs*Q2); + t = 3.0f - r1*hfx; + e = hxs*((r1-t)/(6.0f - x*t)); if (k == 0) /* c is 0 */ return x - (x*e-hxs); SET_FLOAT_WORD(twopk, 0x3f800000+(k<<23)); /* 2^k */ e = x*(e-c) - c; e -= hxs; if (k == -1) - return (float)0.5*(x-e) - (float)0.5; + return 0.5f*(x-e) - 0.5f; if (k == 1) { - if (x < (float)-0.25) - return -(float)2.0*(e-(x+(float)0.5)); - return one+(float)2.0*(x-e); + if (x < -0.25f) + return -2.0f*(e-(x+0.5f)); + return 1.0f + 2.0f*(x-e); } if (k <= -2 || k > 56) { /* suffice to return exp(x)-1 */ - y = one - (e - x); + y = 1.0f - (e - x); if (k == 128) - y = y*2.0F*0x1p127F; + y = y*2.0f*0x1p127f; else y = y*twopk; - return y - one; + return y - 1.0f; } - t = one; + t = 1.0f; if (k < 23) { SET_FLOAT_WORD(t, 0x3f800000 - (0x1000000>>k)); /* t=1-2^-k */ y = t - (e - x); y = y*twopk; } else { - SET_FLOAT_WORD(t, ((0x7f-k)<<23)); /* 2^-k */ + SET_FLOAT_WORD(t, (0x7f-k)<<23); /* 2^-k */ y = x - (e + t); - y += one; + y += 1.0f; y = y*twopk; } return y;