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.

erand48

drand48.erand48
fn erand48(xsubi: *[3]c_ushort) callconv(.c) f64

File

lib/c/stdlib/drand48.zig:32

Code

fn erand48(xsubi: *[3]c_ushort) callconv(.c) f64 {
    const xi = @as(u48, @as(u16, @truncate(xsubi[0])) | (@as(u48, @as(u16, @truncate(xsubi[1])))) << 16) | (@as(u48, @as(u16, @truncate(xsubi[2]))) << 32);

    var separate_lcg: Lcg = .init(xi, lcg.a, lcg.c);
    const next_xi = separate_lcg.next();

    xsubi.* = .{ @truncate(next_xi & 0xFFFF), @truncate((next_xi >> 16) & 0xFFFF), @truncate((next_xi >> 32) & 0xFFFF) };
    return @as(f64, @bitCast(0x3ff0000000000000 | (@as(u64, next_xi) << 4))) - 1.0;
}