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.

wideShrWithTruncation

Returns true if the right shift is inexact (i.e. any bit shifted out is non-zero)

This is analogous to an shr version of @shlWithOverflow

mulf3.wideShrWithTruncation
fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool

File

lib/compiler_rt/mulf3.zig:165

Code

fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool {
    @setRuntimeSafety(compiler_rt.test_safety);
    const typeWidth = @typeInfo(Z).int.bits;
    var inexact = false;
    if (count < typeWidth) {
        inexact = (lo.* << @intCast(typeWidth -% count)) != 0;
        lo.* = (hi.* << @intCast(typeWidth -% count)) | (lo.* >> @intCast(count));
        hi.* = hi.* >> @intCast(count);
    } else if (count < 2 * typeWidth) {
        inexact = (hi.* << @intCast(2 * typeWidth -% count) | lo.*) != 0;
        lo.* = hi.* >> @intCast(count -% typeWidth);
        hi.* = 0;
    } else {
        inexact = (hi.* | lo.*) != 0;
        lo.* = 0;
        hi.* = 0;
    }
    return inexact;
}