Compute 2^(x) using 128-bit precision. TODO(lntue): investigate triple-double precision implementation for this step.
| 113 | // TODO(lntue): investigate triple-double precision implementation for this |
| 114 | // step. |
| 115 | Float128 exp2_f128(double x, int hi, int idx1, int idx2) { |
| 116 | Float128 dx = Float128(x); |
| 117 | |
| 118 | // TODO: Skip recalculating exp_mid1 and exp_mid2. |
| 119 | Float128 exp_mid1 = |
| 120 | fputil::quick_add(Float128(EXP2_MID1[idx1].hi), |
| 121 | fputil::quick_add(Float128(EXP2_MID1[idx1].mid), |
| 122 | Float128(EXP2_MID1[idx1].lo))); |
| 123 | |
| 124 | Float128 exp_mid2 = |
| 125 | fputil::quick_add(Float128(EXP2_MID2[idx2].hi), |
| 126 | fputil::quick_add(Float128(EXP2_MID2[idx2].mid), |
| 127 | Float128(EXP2_MID2[idx2].lo))); |
| 128 | |
| 129 | Float128 exp_mid = fputil::quick_mul(exp_mid1, exp_mid2); |
| 130 | |
| 131 | Float128 p = poly_approx_f128(dx); |
| 132 | |
| 133 | Float128 r = fputil::quick_mul(exp_mid, p); |
| 134 | |
| 135 | r.exponent += hi; |
| 136 | |
| 137 | return r; |
| 138 | } |
| 139 | |
| 140 | // Compute 2^x with double-double precision. |
| 141 | DoubleDouble exp2_double_double(double x, const DoubleDouble &exp_mid) { |
no test coverage detected