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 › asinBinary64
asinBinary64
asin.asinBinary64
fn asinBinary64 (x : f64 ) f64
File
Code
fn asinBinary64 (x : f64 ) f64 {
const pio2_hi : f64 = 1.57079632679489655800e+00 ;
const pio2_lo : f64 = 6.12323399573676603587e-17 ;
const hx : u32 = @intCast (@as (u64 , @bitCast (x )) >> 32 );
const ix = hx & 0x7fffffff ;
if (ix >= 0x3ff0_0000 ) {
const lx : u32 = @truncate (@as (u64 , @bitCast (x )));
if ((ix - 0x3ff0_0000 | lx ) == 0 ) {
return x * pio2_hi + 0x1.0p-120 ;
}
return 0.0 / (x - x );
}
if (ix < 0x3fe0_0000 ) {
if (ix < 0x3e50_0000 and ix >= 0x0010_0000 ) {
return x ;
}
return x + x * rationalApproxBinary64 (x * x );
}
const z = (1.0 - @abs (x )) * 0.5 ;
const s = @sqrt (z );
const r = rationalApproxBinary64 (z );
if (ix >= 0x3fef_3333 ) {
const x_local = pio2_hi - (2 * (s + s * r ) - pio2_lo );
return if (hx >> 31 != 0 ) -x_local else x_local ;
}
const hs : u64 = @bitCast (s );
const f : f64 = @bitCast (hs & 0xffff_ffff_0000_0000 );
const c : f64 = (z - f * f ) / (s + f );
const x_local = 0.5 * pio2_hi - (2.0 * s * r - (pio2_lo - 2.0 * c ) - (0.5 * pio2_hi - 2.0 * f ));
return if (hx >> 31 != 0 ) -x_local else x_local ;
}