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 › sincos
sincos
sincos.sincos
pub fn sincos (x : f64 , r_sin : *f64 , r_cos : *f64 ) callconv (.c ) void
File
Code
pub fn sincos (x : f64 , r_sin : *f64 , r_cos : *f64 ) callconv (.c ) void {
const ix = @as (u32 , @truncate (@as (u64 , @bitCast (x )) >> 32 )) & 0x7fffffff ;
if (ix <= 0x3fe921fb ) {
if (ix < 0x3e46a09e ) {
if (compiler_rt .want_float_exceptions ) {
if (ix < 0x00100000 ) {
mem .doNotOptimizeAway (x / 0x1p120 );
} else {
mem .doNotOptimizeAway (x + 0x1p120 );
}
}
r_sin .* = x ;
r_cos .* = 1.0 ;
return ;
}
r_sin .* = trig .sin (x , 0.0 , 0 );
r_cos .* = trig .cos (x , 0.0 );
return ;
}
if (ix >= 0x7ff00000 ) {
const result = x - x ;
r_sin .* = result ;
r_cos .* = result ;
return ;
}
var y : [2 ]f64 = undefined ;
const n = rem_pio2 (x , &y );
const s = trig .sin (y [0 ], y [1 ], 1 );
const c = trig .cos (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 ;
},
}
}