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 › std/ › math/ › asin.zig › asinBinary32
asinBinary32
asin.asinBinary32
fn asinBinary32 (x : f32 ) f32
File
Code
fn asinBinary32 (x : f32 ) f32 {
const pio2 : f64 = 1.570796326794896558e+00 ;
const hx : u32 = @bitCast (x );
const ix = hx & 0x7fff_ffff ;
if (ix >= 0x3f80_0000 ) {
if (ix == 0x3f80_0000 ) {
return @floatCast (@as (f64 , @floatCast (x )) * pio2 + 0x1.0p-120 );
}
return 0.0 / (x - x );
}
if (ix < 0x3f00_0000 ) {
if (ix < 0x3980_0000 and ix >= 0x0080_0000 ) {
return x ;
}
return x + x * rationalApproxBinary32 (x * x );
}
const z = (1.0 - @abs (x )) * 0.5 ;
const s : f64 = @floatCast (@sqrt (z ));
const x_local : f32 = @floatCast (pio2 - 2.0 * (s + s * @as (f64 , @floatCast (rationalApproxBinary32 (z )))));
return if (hx >> 31 != 0 ) -x_local else x_local ;
}