Commit 3ed9ef3e6b

Andrew Kelley <andrew@ziglang.org>
2022-05-04 06:50:00
Sema: fix bigIntToFloat
The implementation had the `@mulAdd` parameters mixed up.
1 parent b693082
Changed files (3)
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", .{
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;
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);
 }