Lines Matching +full:ulp +full:- +full:0
2 * Double-precision 2^x function.
4 * Copyright (c) 2018-2024, Arm Limited.
5 * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
18 #define C1 __exp_data.exp2_poly[0]
37 if ((ki & 0x80000000) == 0)
39 /* k > 0, the exponent of scale might have overflowed by 1. */
40 sbits -= 1ull << 52;
45 /* k < 0, need special care in the subnormal range. */
52 range to avoid double rounding that can cause 0.5+E/2 ulp error where
53 E is the worst-case ulp error outside the subnormal range. So this
54 is only useful if the goal is better than 1 ulp worst-case error. */
56 lo = scale - y + scale * tmp;
58 lo = 1.0 - hi + y + lo;
59 y = eval_as_double (hi + lo) - 1.0;
60 /* Avoid -0.0 with downward rounding. */
64 force_eval_double (opt_barrier_double (0x1p-1022) * 0x1p-1022);
66 y = 0x1p-1022 * y;
85 abstop = top12 (x) & 0x7ff;
86 if (unlikely (abstop - top12 (0x1p-54) >= top12 (512.0) - top12 (0x1p-54)))
88 if (abstop - top12 (0x1p-54) >= 0x80000000)
90 /* Note: 0 is common input. */
94 if (asuint64 (x) == asuint64 (-INFINITY))
99 return __math_oflow (0);
100 else if (asuint64 (x) >= asuint64 (-1075.0))
101 return __math_uflow (0);
105 abstop = 0;
108 /* exp2(x) = 2^(k/N) * 2^r, with 2^r in [2^(-1/2N),2^(1/2N)]. */
109 /* x = k/N + r, with int k and r in [-1/2N, 1/2N]. */
112 kd -= Shift; /* k/N for int k. */
113 r = x - kd;
116 top = ki << (52 - EXP_TABLE_BITS);
118 /* This is only a valid scale when -1023*N < k < 1024*N. */
120 /* exp2(x) = 2^(k/N) * 2^r ~= scale + scale * (tail + 2^r - 1). */
123 /* Without fma the worst case error is 0.5/N ulp larger. */
124 /* Worst case error is less than 0.5+0.86/N+(abs poly error * 2^53) ulp. */
132 if (unlikely (abstop == 0))
135 /* Note: tmp == 0 or |tmp| > 2^-65 and scale > 2^-928, so there
147 TEST_SIG (S, D, 1, exp2, -9.9, 9.9)
150 TEST_INTERVAL (exp2, 0, 0xffff000000000000, 10000)
151 TEST_SYM_INTERVAL (exp2, 0x1p-6, 0x1p6, 40000)