pub fn cos(x: f64) callconv(.c) f64
pub fn cos(x: f64) callconv(.c) f64 { var ix = @as(u64, @bitCast(x)) >> 32; ix &= 0x7fffffff; // |x| ~< pi/4 if (ix <= 0x3fe921fb) { if (ix < 0x3e46a09e) { // |x| < 2**-27 * sqrt(2) // raise inexact if x!=0 if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120); return 1.0; } return trig.cos(x, 0); } // cos(Inf or NaN) is NaN if (ix >= 0x7ff00000) { return x - x; } var y: [2]f64 = undefined; const n = rem_pio2(x, &y); return switch (n & 3) { 0 => trig.cos(y[0], y[1]), 1 => -trig.sin(y[0], y[1], 1), 2 => -trig.cos(y[0], y[1]), else => trig.sin(y[0], y[1], 1), }; }