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.

ldexp_cexp64

ldexp.ldexp_cexp64
fn ldexp_cexp64(z: Complex(f64), expt: i32) Complex(f64)

File

Code

fn ldexp_cexp64(z: Complex(f64), expt: i32) Complex(f64) {
    var ex_expt: i32 = undefined;
    const exp_x = frexp_exp64(z.re, &ex_expt);
    const exptf = @as(i64, expt + ex_expt);

    const half_expt1 = @divTrunc(exptf, 2);
    const scale1 = @as(f64, @bitCast((0x3ff + half_expt1) << (20 + 32)));

    const half_expt2 = exptf - half_expt1;
    const scale2 = @as(f64, @bitCast((0x3ff + half_expt2) << (20 + 32)));

    return Complex(f64).init(
        @cos(z.im) * exp_x * scale1 * scale2,
        @sin(z.im) * exp_x * scale1 * scale2,
    );
}