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

ldexp_cexp32

Private Function
std.math.complex.ldexp.ldexp_cexp32
fn ldexp_cexp32(z: Complex(f32), expt: i32) Complex(f32)

Params

File

math/complex/ldexp.zig:36
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
fn ldexp_cexp32(z: Complex(f32), expt: i32) Complex(f32) {
    var ex_expt: i32 = undefined;
    const exp_x = frexp_exp32(z.re, &ex_expt);
    const exptf = expt + ex_expt;

    const half_expt1 = @divTrunc(exptf, 2);
    const scale1 = @as(f32, @bitCast((0x7f + half_expt1) << 23));

    const half_expt2 = exptf - half_expt1;
    const scale2 = @as(f32, @bitCast((0x7f + half_expt2) << 23));

    return Complex(f32).init(
        @cos(z.im) * exp_x * scale1 * scale2,
        @sin(z.im) * exp_x * scale1 * scale2,
    );
}