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

acosBinary32

Private Function
std.math.acos.acosBinary32
fn acosBinary32(x: f32) f32

Params

  • x: f32

File

math/acos.zig:107
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
fn acosBinary32(x: f32) f32 {
    const pio2_hi: f32 = 1.5707962513e+00;
    const pio2_lo: f32 = 7.5497894159e-08;

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

    // |x| >= 1 or nan
    if (ix >= 0x3f800000) {
        if (ix == 0x3f800000) {
            if (hx >> 31 != 0) {
                return 2.0 * pio2_hi + 0x1.0p-120;
            }
            return 0.0;
        }
        return 0.0 / (x - x);
    }

    // |x| < 0.5
    if (ix < 0x3f00_0000) {
        // |x| < 2^(-26)
        if (ix <= 0x3280_0000) {
            return pio2_hi + 0x1.0p-120;
        }
        return pio2_hi - (x - (pio2_lo - x * rationalApproxBinary32(x * x)));
    }

    // x < -0.5
    if (hx >> 31 != 0) {
        const z = (1 + x) * 0.5;
        const s = @sqrt(z);
        const w = rationalApproxBinary32(z) * s - pio2_lo;
        return 2.0 * (pio2_hi - (s + w));
    }

    // x > 0.5
    const z = (1.0 - x) * 0.5;
    const s = @sqrt(z);
    const hs: u32 = @bitCast(s);
    const df: f32 = @bitCast(hs & 0xffff_f000);
    const c = (z - df * df) / (s + df);
    const w = rationalApproxBinary32(z) * s + c;
    return 2.0 * (df + w);
}