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.

rintl

math.rintl
fn rintl(x: c_longdouble) callconv(.c) c_longdouble

File

lib/c/math.zig:399

Code

fn rintl(x: c_longdouble) callconv(.c) c_longdouble {
    if (@typeInfo(c_longdouble).float.bits == 64)
        return rint(x);

    const toint: c_longdouble = 1 << math.floatFractionalBits(c_longdouble);
    const se = ld.signExponent(x);

    if (se & 0x7fff >= 0x3fff + math.floatFractionalBits(c_longdouble))
        return x;

    var y: c_longdouble = undefined;
    if ((se >> 15) == 1) {
        y = x - toint + toint;
    } else {
        y = x + toint - toint;
    }

    if (y == 0)
        return 0 * x;
    return y;
}