diff options
Diffstat (limited to 'lib/std/math/complex/ldexp.zig')
| -rw-r--r-- | lib/std/math/complex/ldexp.zig | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/std/math/complex/ldexp.zig b/lib/std/math/complex/ldexp.zig index 9f31aae549..51ac105256 100644 --- a/lib/std/math/complex/ldexp.zig +++ b/lib/std/math/complex/ldexp.zig @@ -13,6 +13,7 @@ const std = @import("../../std.zig"); const debug = std.debug; const math = std.math; const cmath = math.complex; +const testing = std.testing; const Complex = cmath.Complex; /// Returns exp(z) scaled to avoid overflow. @@ -48,7 +49,10 @@ fn ldexp_cexp32(z: Complex(f32), expt: i32) Complex(f32) { const half_expt2 = exptf - half_expt1; const scale2 = @bitCast(f32, (0x7f + half_expt2) << 23); - return Complex(f32).init(math.cos(z.im) * exp_x * scale1 * scale2, math.sin(z.im) * exp_x * scale1 * scale2); + return Complex(f32).init( + math.cos(z.im) * exp_x * scale1 * scale2, + math.sin(z.im) * exp_x * scale1 * scale2, + ); } fn frexp_exp64(x: f64, expt: *i32) f64 { @@ -57,7 +61,7 @@ fn frexp_exp64(x: f64, expt: *i32) f64 { const exp_x = math.exp(x - kln2); - const fx = @bitCast(u64, x); + const fx = @bitCast(u64, exp_x); const hx = @intCast(u32, fx >> 32); const lx = @truncate(u32, fx); @@ -73,10 +77,10 @@ fn ldexp_cexp64(z: Complex(f64), expt: i32) Complex(f64) { const exptf = @as(i64, expt + ex_expt); const half_expt1 = @divTrunc(exptf, 2); - const scale1 = @bitCast(f64, (0x3ff + half_expt1) << 20); + const scale1 = @bitCast(f64, (0x3ff + half_expt1) << (20 + 32)); const half_expt2 = exptf - half_expt1; - const scale2 = @bitCast(f64, (0x3ff + half_expt2) << 20); + const scale2 = @bitCast(f64, (0x3ff + half_expt2) << (20 + 32)); return Complex(f64).init( math.cos(z.im) * exp_x * scale1 * scale2, |
