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.

frexp_exp64

ldexp.frexp_exp64
fn frexp_exp64(x: f64, expt: *i32) f64

File

Code

fn frexp_exp64(x: f64, expt: *i32) f64 {
    const k = 1799; // reduction constant
    const kln2 = 1246.97177782734161156; // k * ln2

    const exp_x = @exp(x - kln2);

    const fx = @as(u64, @bitCast(exp_x));
    const hx = @as(u32, @intCast(fx >> 32));
    const lx = @as(u32, @truncate(fx));

    expt.* = @as(i32, @intCast(hx >> 20)) - (0x3ff + 1023) + k;

    const high_word = (hx & 0xfffff) | ((0x3ff + 1023) << 20);
    return @as(f64, @bitCast((@as(u64, high_word) << 32) | lx));
}