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.

parityXi2

parity.parityXi2
inline fn parityXi2(comptime T: type, a: T) i32

File

lib/compiler_rt/parity.zig:23

Code

inline fn parityXi2(comptime T: type, a: T) i32 {
    var x: @Int(.unsigned, @typeInfo(T).int.bits) = @bitCast(a);
    // Bit Twiddling Hacks: Compute parity in parallel
    comptime var shift: u8 = @bitSizeOf(T) / 2;
    inline while (shift > 2) {
        x ^= x >> shift;
        shift = shift >> 1;
    }
    x &= 0xf;
    return (@as(u16, 0x6996) >> @intCast(x)) & 1; // optimization for >>2 and >>1
}