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/ › sincos.zig › sincosx
sincosx
sincos.sincosx
pub fn sincosx (x : f80 , r_sin : *f80 , r_cos : *f80 ) callconv (.c ) void
File
Code
pub fn sincosx (x : f80 , r_sin : *f80 , r_cos : *f80 ) callconv (.c ) void {
const se = ld .signExponent (x ) & 0x7fff ;
if (se == 0x7fff ) {
const result = x - x ;
r_sin .* = result ;
r_cos .* = result ;
return ;
}
if (@abs (x ) < trig .pi_4 ) {
if (se < 0x3fff - math .floatMantissaBits (f80 )) {
if (compiler_rt .want_float_exceptions and se == 0 ) {
mem .doNotOptimizeAway (x * 0x1p-120 );
}
r_sin .* = x ;
r_cos .* = 1.0 + x ;
return ;
}
r_sin .* = trig .sinx (x , 0.0 , 0 );
r_cos .* = trig .cosx (x , 0.0 );
return ;
}
var y : [2 ]f80 = undefined ;
const n = rem_pio2l (f80 , x , &y );
const s = trig .sinx (y [0 ], y [1 ], 1 );
const c = trig .cosx (y [0 ], y [1 ]);
switch (n & 3 ) {
0 => {
r_sin .* = s ;
r_cos .* = c ;
},
1 => {
r_sin .* = c ;
r_cos .* = -s ;
},
2 => {
r_sin .* = -s ;
r_cos .* = -c ;
},
else => {
r_sin .* = -c ;
r_cos .* = s ;
},
}
}