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.

testSincosSpecial

sincos.testSincosSpecial
fn testSincosSpecial(comptime T: type) !void

File

lib/compiler_rt/sincos.zig:302

Code

fn testSincosSpecial(comptime T: type) !void {
    const f = switch (T) {
        f32 => sincosf,
        f64 => sincos,
        f80 => sincosx,
        f128 => sincosq,
        else => @compileError("unimplemented"),
    };

    var s: T = undefined;
    var c: T = undefined;

    f(0.0, &s, &c);
    try expect(math.isPositiveZero(s));
    try expect(c == 1.0);

    f(-0.0, &s, &c);
    try expect(math.isNegativeZero(s));
    try expect(c == 1.0);

    f(math.inf(T), &s, &c);
    try expect(math.isNan(s));
    try expect(math.isNan(c));

    f(-math.inf(T), &s, &c);
    try expect(math.isNan(s));
    try expect(math.isNan(c));

    f(math.nan(T), &s, &c);
    try expect(math.isNan(s));
    try expect(math.isNan(c));
}