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.

asinBinary16

asin.asinBinary16
fn asinBinary16(x: f16) f16

File

lib/std/math/asin.zig:55

Code

fn asinBinary16(x: f16) f16 {
    const pio2: f32 = math.pi / 2.0;

    const hx: u16 = @bitCast(x);
    const ix = hx & 0x7fff;

    // |x| >= 1
    if (ix >= 0x3c00) {
        // |x| == 1
        if (ix == 0x3c00) {
            // asin(+-1) = +-pi/2 with inexact
            return @floatCast(x * pio2 + 0x1.0p-120);
        }
        // asin(|x| > 1) is nan
        return 0.0 / (x - x);
    }

    // |x| < 0.5
    if (ix < 0x3800) {
        return @floatCast(x * approxBinary16(x * x));
    }

    // 1 > |x| >= 0.5
    const z = (1.0 - @abs(x)) * 0.5;
    const s = @sqrt(z);
    const x_local = pio2 - 2.0 * s * approxBinary16(z);
    if (hx >> 15 != 0) {
        return @floatCast(-x_local);
    }
    return @floatCast(x_local);
}