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.

alignBackward

Round an address down to the previous (or current) aligned address. The alignment must be a power of 2 and greater than 0.

mem.alignBackward
pub fn alignBackward(comptime T: type, addr: T, alignment: T) T

File

lib/std/mem.zig:4890

Code

pub fn alignBackward(comptime T: type, addr: T, alignment: T) T {
    assert(isValidAlignGeneric(T, alignment));
    // 000010000 // example alignment
    // 000001111 // subtract 1
    // 111110000 // binary not
    return addr & ~(alignment - 1);
}