From 3ed9ef3e6bed3fef6d6cad07920d08b28e20ec3e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 3 May 2022 21:50:00 -0700 Subject: [PATCH] Sema: fix bigIntToFloat The implementation had the `@mulAdd` parameters mixed up. --- src/Sema.zig | 4 ++-- src/value.zig | 2 +- test/behavior/floatop.zig | 13 ------------- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Sema.zig b/src/Sema.zig index d9c2d1cc2a..3ad9550175 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -19730,8 +19730,8 @@ fn bitCast( try sema.resolveTypeLayout(block, inst_src, old_ty); const target = sema.mod.getTarget(); - var dest_bits = dest_ty.bitSize(target); - var old_bits = old_ty.bitSize(target); + const dest_bits = dest_ty.bitSize(target); + const old_bits = old_ty.bitSize(target); if (old_bits != dest_bits) { return sema.fail(block, inst_src, "@bitCast size mismatch: destination type '{}' has {d} bits but source type '{}' has {d} bits", .{ diff --git a/src/value.zig b/src/value.zig index adfe4600f8..e8ccada8ed 100644 --- a/src/value.zig +++ b/src/value.zig @@ -1476,7 +1476,7 @@ pub const Value = extern union { while (i != 0) { i -= 1; const limb: f128 = @intToFloat(f128, limbs[i]); - result = @mulAdd(f128, base, limb, result); + result = @mulAdd(f128, base, result, limb); } if (positive) { return result; diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig index c02c1c15c4..536c365655 100644 --- a/test/behavior/floatop.zig +++ b/test/behavior/floatop.zig @@ -667,24 +667,11 @@ fn fnWithFloatMode() f32 { } test "float literal at compile time not lossy" { - if (builtin.zig_backend != .stage1) { - // https://github.com/ziglang/zig/issues/11169 - return error.SkipZigTest; - } - try expect(16777216.0 + 1.0 == 16777217.0); try expect(9007199254740992.0 + 1.0 == 9007199254740993.0); } test "f128 at compile time is lossy" { - if (builtin.zig_backend != .stage1) { - // this one is happening because we represent comptime-known f128 integers with - // Value.Tag.bigint and only convert to f128 representation if it stops being an - // integer. Is this something we want? need to have a lang spec discussion on this - // topic. - return error.SkipZigTest; // TODO - } - try expect(@as(f128, 10384593717069655257060992658440192.0) + 1 == 10384593717069655257060992658440192.0); }