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.

Log2IntCeil

Returns an unsigned int type that can hold the number of bits in T.

math.Log2IntCeil
pub fn Log2IntCeil(comptime T: type) type

File

lib/std/math.zig:791

Code

pub fn Log2IntCeil(comptime T: type) type {
    // comptime ceil log2
    if (T == comptime_int) return comptime_int;
    const bits: u16 = @typeInfo(T).int.bits;
    const log2_bits = 16 - @clz(bits);
    return @Int(.unsigned, log2_bits);
}