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

Compute a^x or a^x - 1, depending on cfg.

exp_f128.proc1
fn proc1(comptime cfg: Config, x: f128) f128

File

lib/compiler_rt/exp_f128.zig:118

Code

fn proc1(comptime cfg: Config, x: f128) f128 {
    // Argument reduction: x = r * 2^(j / size + m)
    // with r in [-log_a(2) / 2 / size, log_a(2) / 2 / size].
    //
    // r computed as r_hi + r_lo to simulate higher precision.
    const n = @round(x * cfg.inv_log_size);
    const ni: i32 = @intFromFloat(n);
    const n2 = @mod(ni, size);
    const n1 = ni - n2;
    const m = @divExact(n1, size);
    const j: usize = @intCast(n2);

    const r_hi = x - n * cfg.log_size_hi;
    const r_lo = n * cfg.neg_log_size_lo;

    const pr = cfg.poly(r_hi, r_lo);

    return cfg.finalize(pr, j, m);
}