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 › sinf
sinf
sin.sinf
pub fn sinf (x : f32 ) callconv (.c ) f32
File
Code
pub fn sinf (x : f32 ) callconv (.c ) f32 {
const s1pio2 : f64 = 1.0 * math .pi / 2.0 ;
const s2pio2 : f64 = 2.0 * math .pi / 2.0 ;
const s3pio2 : f64 = 3.0 * math .pi / 2.0 ;
const s4pio2 : f64 = 4.0 * math .pi / 2.0 ;
var ix : u32 = @bitCast (x );
const sign = ix >> 31 != 0 ;
ix &= 0x7fffffff ;
if (ix <= 0x3f490fda ) {
if (ix < 0x39800000 ) {
// raise inexact if x!=0 and underflow if subnormal
if (compiler_rt .want_float_exceptions ) {
if (ix < 0x00800000 ) {
mem .doNotOptimizeAway (x / 0x1p120 );
} else {
mem .doNotOptimizeAway (x + 0x1p120 );
}
}
return x ;
}
return trig .sindf (x );
}
if (ix <= 0x407b53d1 ) {
if (ix <= 0x4016cbe3 ) {
if (sign ) {
return -trig .cosdf (x + s1pio2 );
} else {
return trig .cosdf (x - s1pio2 );
}
}
return trig .sindf (if (sign ) -(x + s2pio2 ) else -(x - s2pio2 ));
}
if (ix <= 0x40e231d5 ) {
if (ix <= 0x40afeddf ) {
if (sign ) {
return trig .cosdf (x + s3pio2 );
} else {
return -trig .cosdf (x - s3pio2 );
}
}
return trig .sindf (if (sign ) x + s4pio2 else x - s4pio2 );
}
if (ix >= 0x7f800000 ) {
return x - x ;
}
var y : f64 = undefined ;
const n = rem_pio2f (x , &y );
return switch (n & 3 ) {
0 => trig .sindf (y ),
1 => trig .cosdf (y ),
2 => trig .sindf (-y ),
else => -trig .cosdf (y ),
};
}