fn sinpi(comptime T: type, x: T) T
fn sinpi(comptime T: type, x: T) T { const xmod2 = @mod(x, 2); // [0, 2] const n = (@as(u8, @intFromFloat(4 * xmod2)) + 1) / 2; // {0, 1, 2, 3, 4} const y = xmod2 - 0.5 * @as(T, @floatFromInt(n)); // [-0.25, 0.25] return switch (n) { 0, 4 => @sin(std.math.pi * y), 1 => @cos(std.math.pi * y), 2 => -@sin(std.math.pi * y), 3 => -@cos(std.math.pi * y), else => unreachable, }; }