Sema: fix bigIntToFloat

The implementation had the `@mulAdd` parameters mixed up.
This commit is contained in:
Andrew Kelley 2022-05-03 21:50:00 -07:00
parent b6930825b0
commit 3ed9ef3e6b
3 changed files with 3 additions and 16 deletions

View File

@ -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", .{

View File

@ -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;

View File

@ -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);
}