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.

proc1

log_f128.proc1
pub fn proc1(comptime p: Proc1, x: f128) f128

File

lib/compiler_rt/log_f128.zig:55

Code

pub fn proc1(comptime p: Proc1, x: f128) f128 {
    const ym = frexp2(x);
    const y = ym.significand;
    const m = ym.exponent;

    const F0 = @round(math.ldexp(y, log2size));
    const j0: usize = @intFromFloat(F0);
    const j = j0 - size;
    const F = math.ldexp(F0, -log2size);
    const f = y - F;

    const u = (f + f) / (y + F);
    const v = u * u;
    const v64: f64 = @floatCast(v);

    const p9 = p.poly.a9 + v64 * p.poly.a11;
    const p7 = p.poly.a7 + v * p9;
    const p5 = p.poly.a5 + v * p7;
    const p3 = p.poly.a3 + v * p5;

    const q = u * v * p3;

    const xm: f128 = @floatFromInt(m);
    const l_hi = xm * p.tab[128].hi + p.tab[j].hi;
    const l_lo = xm * p.tab[128].lo + p.tab[j].lo;

    if (comptime p.poly.a1 == 1.0)
        return l_hi + (u + (q + l_lo))
    else
        return l_hi + (u * p.poly.a1 + (q + l_lo));
}