Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

expPoly

Approximates e^(r_hi + r_lo) - 1.

exp_f128.expPoly
fn expPoly(r_hi: f128, r_lo: f128) f128

File

lib/compiler_rt/exp_f128.zig:62

Code

fn expPoly(r_hi: f128, r_lo: f128) f128 {
    const a2: f128 = 0.5000000000000000000000000000000001;
    const a3: f128 = 0.16666666666666666666666666666666673;
    const a4: f128 = 4.16666666666666666666666665159063e-2;
    const a5: f128 = 8.333333333333333333333333293907277e-3;
    const a6: f128 = 1.3888888888888888889300177029864553e-3;
    const a7: f128 = 1.984126984126984127049928848046117e-4;
    const a8: f64 = 2.4801587301583374475925191558926944e-5;
    const a9: f64 = 2.7557319223981316410138550193306495e-6;
    const a10: f64 = 2.75573345290144319034653394989056e-7;
    const a11: f64 = 2.5052122512857680160207187885276378e-8;

    const r = r_hi + r_lo;
    const s: f64 = @floatCast(r);
    const rr = r * r;
    const ss = s * s;

    // Do the upper degree computation in f64 and try to get better ILP
    // by deviating from Horner's method. This does not measurably hurt
    // accuracy.
    const a10_11 = a10 + s * a11;
    const a8_9 = a8 + s * a9;
    const a8_11 = a8_9 + ss * a10_11;
    const a6_7 = a6 + r * a7;
    const a4_5 = a4 + r * a5;
    const a2_3 = a2 + r * a3;
    const a2_11 = a2_3 + rr * (a4_5 + rr * (a6_7 + rr * a8_11));

    return r_hi + (r_lo + rr * a2_11);
}