Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Private Function

asinBinary16

Private Function
std.math.asin.asinBinary16
fn asinBinary16(x: f16) f16

Params

  • x: f16

File

math/asin.zig:55
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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);
}