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.

ashlXi3

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

File

lib/compiler_rt/shift.zig:30

Code

inline fn ashlXi3(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.low = 0;
        output.s.high = input.s.low << @intCast(b - word_t.bits);
    } else if (b == 0) {
        return a;
    } else {
        output.s.low = input.s.low << @intCast(b);
        output.s.high = input.s.high << @intCast(b);
        output.s.high |= input.s.low >> @intCast(word_t.bits - b);
    }

    return output.all;
}