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 › acosBinary16
acosBinary16
acos.acosBinary16
fn acosBinary16 (x : f16 ) f16
File
Code
fn acosBinary16 (x : f16 ) f16 {
const pio2 : f32 = math .pi / 2.0 ;
const hx : u16 = @bitCast (x );
const ix : u16 = hx & 0x7fff ;
if (ix >= 0x3c00 ) {
if (ix == 0x3c00 ) {
if (hx >> 15 != 0 ) {
return @floatCast (2.0 * pio2 + 0x1p-120 );
}
return 0.0 ;
}
return 0.0 / (x - x );
}
const xf : f32 = @floatCast (x );
if (ix < 0x3800 ) {
return @floatCast (pio2 - xf * approxBinary16 (xf * xf ));
}
if (hx >> 15 != 0 ) {
const z = (1.0 + xf ) * 0.5 ;
const s = @sqrt (z );
const w = approxBinary16 (z ) * s ;
return @floatCast (2.0 * (pio2 - w ));
}
const z = (1.0 - xf ) * 0.5 ;
const s = @sqrt (z );
const w = approxBinary16 (z ) * s ;
return @floatCast (2.0 * w );
}