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.

unordcmp

comparef.unordcmp
pub inline fn unordcmp(comptime T: type, a: T, b: T) i32

File

lib/compiler_rt/comparef.zig:252

Code

pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 {
    const rep_t = @Int(.unsigned, @typeInfo(T).float.bits);

    const significandBits = std.math.floatMantissaBits(T);
    const exponentBits = std.math.floatExponentBits(T);
    const signBit = (@as(rep_t, 1) << (significandBits + exponentBits));
    const absMask = signBit - 1;
    const infRep = @as(rep_t, @bitCast(std.math.inf(T)));

    const aAbs: rep_t = @as(rep_t, @bitCast(a)) & absMask;
    const bAbs: rep_t = @as(rep_t, @bitCast(b)) & absMask;

    return @intFromBool(aAbs > infRep or bAbs > infRep);
}