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_exp32

ldexp.frexp_exp32
fn frexp_exp32(x: f32, expt: *i32) f32

File

Code

fn frexp_exp32(x: f32, expt: *i32) f32 {
    const k = 235; // reduction constant
    const kln2 = 162.88958740; // k * ln2

    const exp_x = @exp(x - kln2);
    const hx = @as(u32, @bitCast(exp_x));
    // TODO zig should allow this cast implicitly because it should know the value is in range
    expt.* = @as(i32, @intCast(hx >> 23)) - (0x7f + 127) + k;
    return @as(f32, @bitCast((hx & 0x7fffff) | ((0x7f + 127) << 23)));
}