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.
Zig › compiler_rt/ › sin.zig › sin
sin
sin.sin
pub fn sin (x : f64 ) callconv (.c ) f64
File
Code
pub fn sin (x : f64 ) callconv (.c ) f64 {
var ix = @as (u64 , @bitCast (x )) >> 32 ;
ix &= 0x7fffffff ;
if (ix <= 0x3fe921fb ) {
if (ix < 0x3e500000 ) {
// raise inexact if x != 0 and underflow if subnormal
if (compiler_rt .want_float_exceptions ) {
if (ix < 0x00100000 ) {
mem .doNotOptimizeAway (x / 0x1p120 );
} else {
mem .doNotOptimizeAway (x + 0x1p120 );
}
}
return x ;
}
return trig .sin (x , 0.0 , 0 );
}
if (ix >= 0x7ff00000 ) {
return x - x ;
}
var y : [2 ]f64 = undefined ;
const n = rem_pio2 (x , &y );
return switch (n & 3 ) {
0 => trig .sin (y [0 ], y [1 ], 1 ),
1 => trig .cos (y [0 ], y [1 ]),
2 => -trig .sin (y [0 ], y [1 ], 1 ),
else => -trig .cos (y [0 ], y [1 ]),
};
}