authorgravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2022-01-15 02:52:34+13:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-14 13:29:58-05:00
loga64989ee704255f61639c9714c5a38b4d6eb0a9e
tree841aecfa75d79bcc584a4e123ed451462a3829ab
parentec58ddf46c4e1ac060333c6d0780955acae22442

stage1: fix bigint_init_bigfloat for single-limb negative floats

Fixes #10592.

2 files changed, 7 insertions(+), 1 deletions(-)

src/stage1/bigint.cpp+1-1
......@@ -219,7 +219,7 @@ void bigint_init_bigfloat(BigInt *dest, const BigFloat *op) {
219219 ui64_to_f128M(UINT64_MAX, &max_u64);
220220 if (f128M_le(&abs_val, &max_u64)) {
221221 dest->digit_count = 1;
222 dest->data.digit = f128M_to_ui64(&op->value, softfloat_round_minMag, false);
222 dest->data.digit = f128M_to_ui64(&abs_val, softfloat_round_minMag, false);
223223 bigint_normalize(dest);
224224 return;
225225 }
test/behavior/floatop.zig+6
......@@ -66,3 +66,9 @@ fn testDifferentSizedFloatComparisons() !void {
6666// try expect(@nearbyint(a) == -4);
6767// }
6868//}
69
70test "negative f128 floatToInt at compile-time" {
71 const a: f128 = -2;
72 var b = @floatToInt(i64, a);
73 try expect(@as(i64, -2) == b);
74}