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.

negvXi

negv.negvXi
inline fn negvXi(comptime ST: type, a: ST) ST

File

lib/compiler_rt/negv.zig:27

Code

inline fn negvXi(comptime ST: type, a: ST) ST {
    const UT = switch (ST) {
        i32 => u32,
        i64 => u64,
        i128 => u128,
        else => unreachable,
    };
    const N: UT = @bitSizeOf(ST);
    const min: ST = @as(ST, @bitCast((@as(UT, 1) << (N - 1))));
    if (a == min)
        @panic("compiler_rt negv: overflow");
    return -a;
}