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-02-02 21:09:36-07:00
log06ae13fe359dba7675a02716fd8edbcfbd7751d9
tree3808239b1f1e22a8e8a9a8a7a4225abae0696765
parentdafbc6eb2524d1e8276ceec2cf26cb1d4982e2ad

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}