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.

truncq

trunc.truncq
pub fn truncq(x: f128) callconv(.c) f128

File

lib/compiler_rt/trunc.zig:79

Code

pub fn truncq(x: f128) callconv(.c) f128 {
    const u: u128 = @bitCast(x);
    var e = @as(i32, @intCast(((u >> 112) & 0x7FFF))) - 0x3FFF + 16;
    var m: u128 = undefined;

    if (e >= 112 + 16) {
        return x;
    }
    if (e < 16) {
        e = 1;
    }

    m = @as(u128, math.maxInt(u128)) >> @intCast(e);
    if (u & m == 0) {
        return x;
    } else {
        if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
        return @bitCast(u & ~m);
    }
}