diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-06-24 16:58:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-24 16:58:19 -0700 |
| commit | 146b79af153bbd5dafda0ba12a040385c7fc58f8 (patch) | |
| tree | 67e3db8b444d65c667e314770fc983a7fc8ba293 /lib/std/math/frexp.zig | |
| parent | 13853bef0df3c90633021850cc6d6abaeea03282 (diff) | |
| parent | 21ac0beb436f49fe49c6982a872f2dc48e4bea5e (diff) | |
| download | zig-146b79af153bbd5dafda0ba12a040385c7fc58f8.tar.gz zig-146b79af153bbd5dafda0ba12a040385c7fc58f8.zip | |
Merge pull request #16163 from mlugg/feat/builtins-infer-dest-ty
Infer destination type of cast builtins using result type
Diffstat (limited to 'lib/std/math/frexp.zig')
| -rw-r--r-- | lib/std/math/frexp.zig | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/std/math/frexp.zig b/lib/std/math/frexp.zig index 31168d28d4..f295b959cb 100644 --- a/lib/std/math/frexp.zig +++ b/lib/std/math/frexp.zig @@ -38,8 +38,8 @@ pub fn frexp(x: anytype) Frexp(@TypeOf(x)) { fn frexp32(x: f32) Frexp(f32) { var result: Frexp(f32) = undefined; - var y = @bitCast(u32, x); - const e = @intCast(i32, y >> 23) & 0xFF; + var y = @as(u32, @bitCast(x)); + const e = @as(i32, @intCast(y >> 23)) & 0xFF; if (e == 0) { if (x != 0) { @@ -68,15 +68,15 @@ fn frexp32(x: f32) Frexp(f32) { result.exponent = e - 0x7E; y &= 0x807FFFFF; y |= 0x3F000000; - result.significand = @bitCast(f32, y); + result.significand = @as(f32, @bitCast(y)); return result; } fn frexp64(x: f64) Frexp(f64) { var result: Frexp(f64) = undefined; - var y = @bitCast(u64, x); - const e = @intCast(i32, y >> 52) & 0x7FF; + var y = @as(u64, @bitCast(x)); + const e = @as(i32, @intCast(y >> 52)) & 0x7FF; if (e == 0) { if (x != 0) { @@ -105,15 +105,15 @@ fn frexp64(x: f64) Frexp(f64) { result.exponent = e - 0x3FE; y &= 0x800FFFFFFFFFFFFF; y |= 0x3FE0000000000000; - result.significand = @bitCast(f64, y); + result.significand = @as(f64, @bitCast(y)); return result; } fn frexp128(x: f128) Frexp(f128) { var result: Frexp(f128) = undefined; - var y = @bitCast(u128, x); - const e = @intCast(i32, y >> 112) & 0x7FFF; + var y = @as(u128, @bitCast(x)); + const e = @as(i32, @intCast(y >> 112)) & 0x7FFF; if (e == 0) { if (x != 0) { @@ -142,7 +142,7 @@ fn frexp128(x: f128) Frexp(f128) { result.exponent = e - 0x3FFE; y &= 0x8000FFFFFFFFFFFFFFFFFFFFFFFFFFFF; y |= 0x3FFE0000000000000000000000000000; - result.significand = @bitCast(f128, y); + result.significand = @as(f128, @bitCast(y)); return result; } |
