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 › sincosq
sincosq
sincos.sincosq
pub fn sincosq (x : f128 , r_sin : *f128 , r_cos : *f128 ) callconv (.c ) void
File
Code
pub fn sincosq (x : f128 , r_sin : *f128 , r_cos : *f128 ) 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 (f128 )) {
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 .sinq (x , 0.0 , 0 );
r_cos .* = trig .cosq (x , 0.0 );
return ;
}
var y : [2 ]f128 = undefined ;
const n = rem_pio2l (f128 , x , &y );
const s = trig .sinq (y [0 ], y [1 ], 1 );
const c = trig .cosq (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 ;
},
}
}