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

asinBinary32

Private Function
std.math.asin.asinBinary32
fn asinBinary32(x: f32) f32

Params

  • x: f32

File

math/asin.zig:98
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
fn asinBinary32(x: f32) f32 {
    const pio2: f64 = 1.570796326794896558e+00;

    const hx: u32 = @bitCast(x);
    const ix = hx & 0x7fff_ffff;

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

    // |x| < 0.5
    if (ix < 0x3f00_0000) {
        // 0x1p-126 <= |x| < 0x1p-12
        if (ix < 0x3980_0000 and ix >= 0x0080_0000) {
            return x;
        }
        return x + x * rationalApproxBinary32(x * x);
    }

    // 1 > |x| >= 0.5
    const z = (1.0 - @abs(x)) * 0.5;
    const s: f64 = @floatCast(@sqrt(z));
    const x_local: f32 = @floatCast(pio2 - 2.0 * (s + s * @as(f64, @floatCast(rationalApproxBinary32(z)))));
    return if (hx >> 31 != 0) -x_local else x_local;
}