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/ › acos.zig › acosBinary128
acosBinary128
acos.acosBinary128
fn acosBinary128 (x : f128 ) f128
File
Code
fn acosBinary128 (x : f128 ) f128 {
const pio2_hi : f128 = 1.57079632679489661923132169163975140 ;
const pio2_lo : f128 = 4.33590506506189051239852201302167613e-35 ;
const hx : u128 = @bitCast (x );
const se : u16 = @truncate (hx >> 112 );
const e = se & 0x7fff ;
if (e >= 0x3fff ) {
if (x == 1.0 ) {
return 0.0 ;
}
if (x == -1.0 ) {
return 2 * pio2_hi + 0x1p-120 ;
}
return 0.0 / (x - x );
}
if (e < 0x3fff - 1 ) {
if (e < 0x3fff - math .floatFractionalBits (f128 )) {
return pio2_hi + 0x1p-120 ;
}
return pio2_hi - (rationalApproxBinary128 (x * x ) * x - pio2_lo + x );
}
if (se >> 15 != 0 ) {
const z = (1 + x ) * 0.5 ;
const s = @sqrt (z );
return 2 * (pio2_hi - (rationalApproxBinary128 (z ) * s - pio2_lo + s ));
}
const z = (1.0 - x ) * 0.5 ;
const s = @sqrt (z );
const hs : u128 = @bitCast (s );
const f : f128 = @bitCast (hs & 0xffff_ffff_ffff_ffff_0000_0000_0000_0000 );
const c = (z - f * f ) / (s + f );
return 2.0 * (rationalApproxBinary128 (z ) * s + c + f );
}