1b83ccea3SSteve Kargl /*- 2a1d69112SSteve Kargl * Copyright (c) 2009-2013 Steven G. Kargl 3b83ccea3SSteve Kargl * All rights reserved. 4b83ccea3SSteve Kargl * 5b83ccea3SSteve Kargl * Redistribution and use in source and binary forms, with or without 6b83ccea3SSteve Kargl * modification, are permitted provided that the following conditions 7b83ccea3SSteve Kargl * are met: 8b83ccea3SSteve Kargl * 1. Redistributions of source code must retain the above copyright 9b83ccea3SSteve Kargl * notice unmodified, this list of conditions, and the following 10b83ccea3SSteve Kargl * disclaimer. 11b83ccea3SSteve Kargl * 2. Redistributions in binary form must reproduce the above copyright 12b83ccea3SSteve Kargl * notice, this list of conditions and the following disclaimer in the 13b83ccea3SSteve Kargl * documentation and/or other materials provided with the distribution. 14b83ccea3SSteve Kargl * 15b83ccea3SSteve Kargl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16b83ccea3SSteve Kargl * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17b83ccea3SSteve Kargl * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18b83ccea3SSteve Kargl * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19b83ccea3SSteve Kargl * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20b83ccea3SSteve Kargl * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21b83ccea3SSteve Kargl * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22b83ccea3SSteve Kargl * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23b83ccea3SSteve Kargl * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24b83ccea3SSteve Kargl * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25a3f70b4eSSteve Kargl * 26a3f70b4eSSteve Kargl * Optimized by Bruce D. Evans. 27b83ccea3SSteve Kargl */ 28b83ccea3SSteve Kargl 29b83ccea3SSteve Kargl #include <sys/cdefs.h> 30b83ccea3SSteve Kargl __FBSDID("$FreeBSD$"); 31b83ccea3SSteve Kargl 328f647ffdSSteve Kargl /* 338f647ffdSSteve Kargl * ld128 version of s_expl.c. See ../ld80/s_expl.c for most comments. 348f647ffdSSteve Kargl */ 358f647ffdSSteve Kargl 36b83ccea3SSteve Kargl #include <float.h> 37b83ccea3SSteve Kargl 38f7cfe68fSSteve Kargl #include "fpmath.h" 39b83ccea3SSteve Kargl #include "math.h" 40b83ccea3SSteve Kargl #include "math_private.h" 415f63fbd6SSteve Kargl #include "k_expl.h" 42b83ccea3SSteve Kargl 435f63fbd6SSteve Kargl /* XXX Prevent compilers from erroneously constant folding these: */ 445f63fbd6SSteve Kargl static const volatile long double 455f63fbd6SSteve Kargl huge = 0x1p10000L, 465f63fbd6SSteve Kargl tiny = 0x1p-10000L; 47b83ccea3SSteve Kargl 4831407861SSteve Kargl static const long double 491a287d1dSSteve Kargl twom10000 = 0x1p-10000L; 50b83ccea3SSteve Kargl 51b83ccea3SSteve Kargl static const long double 5231407861SSteve Kargl /* log(2**16384 - 0.5) rounded towards zero: */ 5331407861SSteve Kargl /* log(2**16384 - 0.5 + 1) rounded towards zero for expm1l() is the same: */ 548f647ffdSSteve Kargl o_threshold = 11356.523406294143949491931077970763428L, 5531407861SSteve Kargl /* log(2**(-16381-64-1)) rounded towards zero: */ 568f647ffdSSteve Kargl u_threshold = -11433.462743336297878837243843452621503L; 57b83ccea3SSteve Kargl 58b83ccea3SSteve Kargl long double 59b83ccea3SSteve Kargl expl(long double x) 60b83ccea3SSteve Kargl { 615f63fbd6SSteve Kargl union IEEEl2bits u; 625f63fbd6SSteve Kargl long double hi, lo, t, twopk; 635f63fbd6SSteve Kargl int k; 648cc74771SSteve Kargl uint16_t hx, ix; 65b83ccea3SSteve Kargl 665f63fbd6SSteve Kargl DOPRINT_START(&x); 675f63fbd6SSteve Kargl 68b83ccea3SSteve Kargl /* Filter out exceptional cases. */ 69b83ccea3SSteve Kargl u.e = x; 70b83ccea3SSteve Kargl hx = u.xbits.expsign; 71f7cfe68fSSteve Kargl ix = hx & 0x7fff; 72b83ccea3SSteve Kargl if (ix >= BIAS + 13) { /* |x| >= 8192 or x is NaN */ 73b83ccea3SSteve Kargl if (ix == BIAS + LDBL_MAX_EXP) { 741783063fSSteve Kargl if (hx & 0x8000) /* x is -Inf or -NaN */ 755f63fbd6SSteve Kargl RETURNP(-1 / x); 765f63fbd6SSteve Kargl RETURNP(x + x); /* x is +Inf or +NaN */ 77b83ccea3SSteve Kargl } 78b83ccea3SSteve Kargl if (x > o_threshold) 795f63fbd6SSteve Kargl RETURNP(huge * huge); 80b83ccea3SSteve Kargl if (x < u_threshold) 815f63fbd6SSteve Kargl RETURNP(tiny * tiny); 821783063fSSteve Kargl } else if (ix < BIAS - 114) { /* |x| < 0x1p-114 */ 835f63fbd6SSteve Kargl RETURN2P(1, x); /* 1 with inexact iff x != 0 */ 84b83ccea3SSteve Kargl } 85b83ccea3SSteve Kargl 868cc74771SSteve Kargl ENTERI(); 878cc74771SSteve Kargl 885f63fbd6SSteve Kargl twopk = 1; 895f63fbd6SSteve Kargl __k_expl(x, &hi, &lo, &k); 905f63fbd6SSteve Kargl t = SUM2P(hi, lo); 91b83ccea3SSteve Kargl 92b83ccea3SSteve Kargl /* Scale by 2**k. */ 935f63fbd6SSteve Kargl /* XXX sparc64 multiplication is so slow that scalbnl() is faster. */ 94b83ccea3SSteve Kargl if (k >= LDBL_MIN_EXP) { 95b83ccea3SSteve Kargl if (k == LDBL_MAX_EXP) 968cc74771SSteve Kargl RETURNI(t * 2 * 0x1p16383L); 975f63fbd6SSteve Kargl SET_LDBL_EXPSIGN(twopk, BIAS + k); 988cc74771SSteve Kargl RETURNI(t * twopk); 99b83ccea3SSteve Kargl } else { 1005f63fbd6SSteve Kargl SET_LDBL_EXPSIGN(twopk, BIAS + k + 10000); 1015f63fbd6SSteve Kargl RETURNI(t * twopk * twom10000); 102b83ccea3SSteve Kargl } 103b83ccea3SSteve Kargl } 1043ffff4baSSteve Kargl 1053ffff4baSSteve Kargl /* 1063ffff4baSSteve Kargl * Our T1 and T2 are chosen to be approximately the points where method 1073ffff4baSSteve Kargl * A and method B have the same accuracy. Tang's T1 and T2 are the 1083ffff4baSSteve Kargl * points where method A's accuracy changes by a full bit. For Tang, 1093ffff4baSSteve Kargl * this drop in accuracy makes method A immediately less accurate than 1103ffff4baSSteve Kargl * method B, but our larger INTERVALS makes method A 2 bits more 1113ffff4baSSteve Kargl * accurate so it remains the most accurate method significantly 1123ffff4baSSteve Kargl * closer to the origin despite losing the full bit in our extended 1133ffff4baSSteve Kargl * range for it. 1143ffff4baSSteve Kargl * 1153ffff4baSSteve Kargl * Split the interval [T1, T2] into two intervals [T1, T3] and [T3, T2]. 1163ffff4baSSteve Kargl * Setting T3 to 0 would require the |x| < 0x1p-113 condition to appear 1173ffff4baSSteve Kargl * in both subintervals, so set T3 = 2**-5, which places the condition 1183ffff4baSSteve Kargl * into the [T1, T3] interval. 1195f63fbd6SSteve Kargl * 1205f63fbd6SSteve Kargl * XXX we now do this more to (partially) balance the number of terms 1215f63fbd6SSteve Kargl * in the C and D polys than to avoid checking the condition in both 1225f63fbd6SSteve Kargl * intervals. 1235f63fbd6SSteve Kargl * 1245f63fbd6SSteve Kargl * XXX these micro-optimizations are excessive. 1253ffff4baSSteve Kargl */ 1263ffff4baSSteve Kargl static const double 1273ffff4baSSteve Kargl T1 = -0.1659, /* ~-30.625/128 * log(2) */ 1283ffff4baSSteve Kargl T2 = 0.1659, /* ~30.625/128 * log(2) */ 1293ffff4baSSteve Kargl T3 = 0.03125; 1303ffff4baSSteve Kargl 1313ffff4baSSteve Kargl /* 1323ffff4baSSteve Kargl * Domain [-0.1659, 0.03125], range ~[2.9134e-44, 1.8404e-37]: 1333ffff4baSSteve Kargl * |(exp(x)-1-x-x**2/2)/x - p(x)| < 2**-122.03 134*6202fb7bSDimitry Andric * 1355f63fbd6SSteve Kargl * XXX none of the long double C or D coeffs except C10 is correctly printed. 1365f63fbd6SSteve Kargl * If you re-print their values in %.35Le format, the result is always 1375f63fbd6SSteve Kargl * different. For example, the last 2 digits in C3 should be 59, not 67. 1385f63fbd6SSteve Kargl * 67 is apparently from rounding an extra-precision value to 36 decimal 1395f63fbd6SSteve Kargl * places. 1403ffff4baSSteve Kargl */ 1413ffff4baSSteve Kargl static const long double 1423ffff4baSSteve Kargl C3 = 1.66666666666666666666666666666666667e-1L, 1433ffff4baSSteve Kargl C4 = 4.16666666666666666666666666666666645e-2L, 1443ffff4baSSteve Kargl C5 = 8.33333333333333333333333333333371638e-3L, 1453ffff4baSSteve Kargl C6 = 1.38888888888888888888888888891188658e-3L, 1463ffff4baSSteve Kargl C7 = 1.98412698412698412698412697235950394e-4L, 1473ffff4baSSteve Kargl C8 = 2.48015873015873015873015112487849040e-5L, 1483ffff4baSSteve Kargl C9 = 2.75573192239858906525606685484412005e-6L, 1493ffff4baSSteve Kargl C10 = 2.75573192239858906612966093057020362e-7L, 1503ffff4baSSteve Kargl C11 = 2.50521083854417203619031960151253944e-8L, 1513ffff4baSSteve Kargl C12 = 2.08767569878679576457272282566520649e-9L, 1523ffff4baSSteve Kargl C13 = 1.60590438367252471783548748824255707e-10L; 1533ffff4baSSteve Kargl 1545f63fbd6SSteve Kargl /* 1555f63fbd6SSteve Kargl * XXX this has 1 more coeff than needed. 1565f63fbd6SSteve Kargl * XXX can start the double coeffs but not the double mults at C10. 1575f63fbd6SSteve Kargl * With my coeffs (C10-C17 double; s = best_s): 1585f63fbd6SSteve Kargl * Domain [-0.1659, 0.03125], range ~[-1.1976e-37, 1.1976e-37]: 1595f63fbd6SSteve Kargl * |(exp(x)-1-x-x**2/2)/x - p(x)| ~< 2**-122.65 1605f63fbd6SSteve Kargl */ 1613ffff4baSSteve Kargl static const double 1623ffff4baSSteve Kargl C14 = 1.1470745580491932e-11, /* 0x1.93974a81dae30p-37 */ 1633ffff4baSSteve Kargl C15 = 7.6471620181090468e-13, /* 0x1.ae7f3820adab1p-41 */ 1643ffff4baSSteve Kargl C16 = 4.7793721460260450e-14, /* 0x1.ae7cd18a18eacp-45 */ 1653ffff4baSSteve Kargl C17 = 2.8074757356658877e-15, /* 0x1.949992a1937d9p-49 */ 1663ffff4baSSteve Kargl C18 = 1.4760610323699476e-16; /* 0x1.545b43aabfbcdp-53 */ 1673ffff4baSSteve Kargl 1683ffff4baSSteve Kargl /* 1693ffff4baSSteve Kargl * Domain [0.03125, 0.1659], range ~[-2.7676e-37, -1.0367e-38]: 1703ffff4baSSteve Kargl * |(exp(x)-1-x-x**2/2)/x - p(x)| < 2**-121.44 1713ffff4baSSteve Kargl */ 1723ffff4baSSteve Kargl static const long double 1733ffff4baSSteve Kargl D3 = 1.66666666666666666666666666666682245e-1L, 1743ffff4baSSteve Kargl D4 = 4.16666666666666666666666666634228324e-2L, 1753ffff4baSSteve Kargl D5 = 8.33333333333333333333333364022244481e-3L, 1763ffff4baSSteve Kargl D6 = 1.38888888888888888888887138722762072e-3L, 1773ffff4baSSteve Kargl D7 = 1.98412698412698412699085805424661471e-4L, 1783ffff4baSSteve Kargl D8 = 2.48015873015873015687993712101479612e-5L, 1793ffff4baSSteve Kargl D9 = 2.75573192239858944101036288338208042e-6L, 1803ffff4baSSteve Kargl D10 = 2.75573192239853161148064676533754048e-7L, 1813ffff4baSSteve Kargl D11 = 2.50521083855084570046480450935267433e-8L, 1823ffff4baSSteve Kargl D12 = 2.08767569819738524488686318024854942e-9L, 1833ffff4baSSteve Kargl D13 = 1.60590442297008495301927448122499313e-10L; 1843ffff4baSSteve Kargl 1855f63fbd6SSteve Kargl /* 1865f63fbd6SSteve Kargl * XXX this has 1 more coeff than needed. 1875f63fbd6SSteve Kargl * XXX can start the double coeffs but not the double mults at D11. 1885f63fbd6SSteve Kargl * With my coeffs (D11-D16 double): 1895f63fbd6SSteve Kargl * Domain [0.03125, 0.1659], range ~[-1.1980e-37, 1.1980e-37]: 1905f63fbd6SSteve Kargl * |(exp(x)-1-x-x**2/2)/x - p(x)| ~< 2**-122.65 1915f63fbd6SSteve Kargl */ 1923ffff4baSSteve Kargl static const double 1933ffff4baSSteve Kargl D14 = 1.1470726176204336e-11, /* 0x1.93971dc395d9ep-37 */ 1943ffff4baSSteve Kargl D15 = 7.6478532249581686e-13, /* 0x1.ae892e3D16fcep-41 */ 1953ffff4baSSteve Kargl D16 = 4.7628892832607741e-14, /* 0x1.ad00Dfe41feccp-45 */ 1963ffff4baSSteve Kargl D17 = 3.0524857220358650e-15; /* 0x1.D7e8d886Df921p-49 */ 1973ffff4baSSteve Kargl 1983ffff4baSSteve Kargl long double 1993ffff4baSSteve Kargl expm1l(long double x) 2003ffff4baSSteve Kargl { 2013ffff4baSSteve Kargl union IEEEl2bits u, v; 2023ffff4baSSteve Kargl long double hx2_hi, hx2_lo, q, r, r1, t, twomk, twopk, x_hi; 2033ffff4baSSteve Kargl long double x_lo, x2; 2043ffff4baSSteve Kargl double dr, dx, fn, r2; 2053ffff4baSSteve Kargl int k, n, n2; 2063ffff4baSSteve Kargl uint16_t hx, ix; 2073ffff4baSSteve Kargl 2085f63fbd6SSteve Kargl DOPRINT_START(&x); 2095f63fbd6SSteve Kargl 2103ffff4baSSteve Kargl /* Filter out exceptional cases. */ 2113ffff4baSSteve Kargl u.e = x; 2123ffff4baSSteve Kargl hx = u.xbits.expsign; 2133ffff4baSSteve Kargl ix = hx & 0x7fff; 2143ffff4baSSteve Kargl if (ix >= BIAS + 7) { /* |x| >= 128 or x is NaN */ 2153ffff4baSSteve Kargl if (ix == BIAS + LDBL_MAX_EXP) { 2163ffff4baSSteve Kargl if (hx & 0x8000) /* x is -Inf or -NaN */ 2175f63fbd6SSteve Kargl RETURNP(-1 / x - 1); 2185f63fbd6SSteve Kargl RETURNP(x + x); /* x is +Inf or +NaN */ 2193ffff4baSSteve Kargl } 2203ffff4baSSteve Kargl if (x > o_threshold) 2215f63fbd6SSteve Kargl RETURNP(huge * huge); 2223ffff4baSSteve Kargl /* 2233ffff4baSSteve Kargl * expm1l() never underflows, but it must avoid 2243ffff4baSSteve Kargl * unrepresentable large negative exponents. We used a 2253ffff4baSSteve Kargl * much smaller threshold for large |x| above than in 2263ffff4baSSteve Kargl * expl() so as to handle not so large negative exponents 2273ffff4baSSteve Kargl * in the same way as large ones here. 2283ffff4baSSteve Kargl */ 2293ffff4baSSteve Kargl if (hx & 0x8000) /* x <= -128 */ 2305f63fbd6SSteve Kargl RETURN2P(tiny, -1); /* good for x < -114ln2 - eps */ 2313ffff4baSSteve Kargl } 2323ffff4baSSteve Kargl 2333ffff4baSSteve Kargl ENTERI(); 2343ffff4baSSteve Kargl 2353ffff4baSSteve Kargl if (T1 < x && x < T2) { 2363ffff4baSSteve Kargl x2 = x * x; 2373ffff4baSSteve Kargl dx = x; 2383ffff4baSSteve Kargl 2393ffff4baSSteve Kargl if (x < T3) { 2403ffff4baSSteve Kargl if (ix < BIAS - 113) { /* |x| < 0x1p-113 */ 2413ffff4baSSteve Kargl /* x (rounded) with inexact if x != 0: */ 2425f63fbd6SSteve Kargl RETURNPI(x == 0 ? x : 2433ffff4baSSteve Kargl (0x1p200 * x + fabsl(x)) * 0x1p-200); 2443ffff4baSSteve Kargl } 2453ffff4baSSteve Kargl q = x * x2 * C3 + x2 * x2 * (C4 + x * (C5 + x * (C6 + 2463ffff4baSSteve Kargl x * (C7 + x * (C8 + x * (C9 + x * (C10 + 2473ffff4baSSteve Kargl x * (C11 + x * (C12 + x * (C13 + 2483ffff4baSSteve Kargl dx * (C14 + dx * (C15 + dx * (C16 + 2493ffff4baSSteve Kargl dx * (C17 + dx * C18)))))))))))))); 2503ffff4baSSteve Kargl } else { 2513ffff4baSSteve Kargl q = x * x2 * D3 + x2 * x2 * (D4 + x * (D5 + x * (D6 + 2523ffff4baSSteve Kargl x * (D7 + x * (D8 + x * (D9 + x * (D10 + 2533ffff4baSSteve Kargl x * (D11 + x * (D12 + x * (D13 + 2543ffff4baSSteve Kargl dx * (D14 + dx * (D15 + dx * (D16 + 2553ffff4baSSteve Kargl dx * D17))))))))))))); 2563ffff4baSSteve Kargl } 2573ffff4baSSteve Kargl 2583ffff4baSSteve Kargl x_hi = (float)x; 2593ffff4baSSteve Kargl x_lo = x - x_hi; 2603ffff4baSSteve Kargl hx2_hi = x_hi * x_hi / 2; 2613ffff4baSSteve Kargl hx2_lo = x_lo * (x + x_hi) / 2; 2623ffff4baSSteve Kargl if (ix >= BIAS - 7) 2635f63fbd6SSteve Kargl RETURN2PI(hx2_hi + x_hi, hx2_lo + x_lo + q); 2643ffff4baSSteve Kargl else 2655f63fbd6SSteve Kargl RETURN2PI(x, hx2_lo + q + hx2_hi); 2663ffff4baSSteve Kargl } 2673ffff4baSSteve Kargl 2683ffff4baSSteve Kargl /* Reduce x to (k*ln2 + endpoint[n2] + r1 + r2). */ 2693ffff4baSSteve Kargl /* Use a specialized rint() to get fn. Assume round-to-nearest. */ 2703ffff4baSSteve Kargl fn = (double)x * INV_L + 0x1.8p52 - 0x1.8p52; 2713ffff4baSSteve Kargl #if defined(HAVE_EFFICIENT_IRINT) 2723ffff4baSSteve Kargl n = irint(fn); 2733ffff4baSSteve Kargl #else 2743ffff4baSSteve Kargl n = (int)fn; 2753ffff4baSSteve Kargl #endif 2763ffff4baSSteve Kargl n2 = (unsigned)n % INTERVALS; 2773ffff4baSSteve Kargl k = n >> LOG2_INTERVALS; 2783ffff4baSSteve Kargl r1 = x - fn * L1; 2793ffff4baSSteve Kargl r2 = fn * -L2; 2803ffff4baSSteve Kargl r = r1 + r2; 2813ffff4baSSteve Kargl 2823ffff4baSSteve Kargl /* Prepare scale factor. */ 2833ffff4baSSteve Kargl v.e = 1; 2843ffff4baSSteve Kargl v.xbits.expsign = BIAS + k; 2853ffff4baSSteve Kargl twopk = v.e; 2863ffff4baSSteve Kargl 2873ffff4baSSteve Kargl /* 2883ffff4baSSteve Kargl * Evaluate lower terms of 2893ffff4baSSteve Kargl * expl(endpoint[n2] + r1 + r2) = tbl[n2] * expl(r1 + r2). 2903ffff4baSSteve Kargl */ 2913ffff4baSSteve Kargl dr = r; 2923ffff4baSSteve Kargl q = r2 + r * r * (A2 + r * (A3 + r * (A4 + r * (A5 + r * (A6 + 2933ffff4baSSteve Kargl dr * (A7 + dr * (A8 + dr * (A9 + dr * A10)))))))); 2943ffff4baSSteve Kargl 2953ffff4baSSteve Kargl t = tbl[n2].lo + tbl[n2].hi; 2963ffff4baSSteve Kargl 2973ffff4baSSteve Kargl if (k == 0) { 2985f63fbd6SSteve Kargl t = SUM2P(tbl[n2].hi - 1, tbl[n2].lo * (r1 + 1) + t * q + 2995f63fbd6SSteve Kargl tbl[n2].hi * r1); 3003ffff4baSSteve Kargl RETURNI(t); 3013ffff4baSSteve Kargl } 3023ffff4baSSteve Kargl if (k == -1) { 3035f63fbd6SSteve Kargl t = SUM2P(tbl[n2].hi - 2, tbl[n2].lo * (r1 + 1) + t * q + 3045f63fbd6SSteve Kargl tbl[n2].hi * r1); 3053ffff4baSSteve Kargl RETURNI(t / 2); 3063ffff4baSSteve Kargl } 3073ffff4baSSteve Kargl if (k < -7) { 3085f63fbd6SSteve Kargl t = SUM2P(tbl[n2].hi, tbl[n2].lo + t * (q + r1)); 3093ffff4baSSteve Kargl RETURNI(t * twopk - 1); 3103ffff4baSSteve Kargl } 3113ffff4baSSteve Kargl if (k > 2 * LDBL_MANT_DIG - 1) { 3125f63fbd6SSteve Kargl t = SUM2P(tbl[n2].hi, tbl[n2].lo + t * (q + r1)); 3133ffff4baSSteve Kargl if (k == LDBL_MAX_EXP) 3143ffff4baSSteve Kargl RETURNI(t * 2 * 0x1p16383L - 1); 3153ffff4baSSteve Kargl RETURNI(t * twopk - 1); 3163ffff4baSSteve Kargl } 3173ffff4baSSteve Kargl 3183ffff4baSSteve Kargl v.xbits.expsign = BIAS - k; 3193ffff4baSSteve Kargl twomk = v.e; 3203ffff4baSSteve Kargl 3213ffff4baSSteve Kargl if (k > LDBL_MANT_DIG - 1) 3225f63fbd6SSteve Kargl t = SUM2P(tbl[n2].hi, tbl[n2].lo - twomk + t * (q + r1)); 3233ffff4baSSteve Kargl else 3245f63fbd6SSteve Kargl t = SUM2P(tbl[n2].hi - twomk, tbl[n2].lo + t * (q + r1)); 3253ffff4baSSteve Kargl RETURNI(t * twopk); 3263ffff4baSSteve Kargl } 327