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.

lshrXi3

shift.lshrXi3
inline fn lshrXi3(comptime T: type, a: T, b: i32) T

File

lib/compiler_rt/shift.zig:75

Code

inline fn lshrXi3(comptime T: type, a: T, b: i32) T {
    const word_t = compiler_rt.HalveInt(T, false);

    const input = word_t{ .all = a };
    var output: word_t = undefined;

    if (b >= word_t.bits) {
        output.s.high = 0;
        output.s.low = input.s.high >> @intCast(b - word_t.bits);
    } else if (b == 0) {
        return a;
    } else {
        output.s.high = input.s.high >> @intCast(b);
        output.s.low = input.s.high << @intCast(word_t.bits - b);
        output.s.low |= input.s.low >> @intCast(b);
    }

    return output.all;
}