mirror of
https://github.com/ziglang/zig.git
synced 2025-12-13 01:33:09 +00:00
stage1: fix bigint_init_bigfloat for single-limb negative floats
Fixes #10592.
This commit is contained in:
parent
dafbc6eb25
commit
06ae13fe35
@ -219,7 +219,7 @@ void bigint_init_bigfloat(BigInt *dest, const BigFloat *op) {
|
|||||||
ui64_to_f128M(UINT64_MAX, &max_u64);
|
ui64_to_f128M(UINT64_MAX, &max_u64);
|
||||||
if (f128M_le(&abs_val, &max_u64)) {
|
if (f128M_le(&abs_val, &max_u64)) {
|
||||||
dest->digit_count = 1;
|
dest->digit_count = 1;
|
||||||
dest->data.digit = f128M_to_ui64(&op->value, softfloat_round_minMag, false);
|
dest->data.digit = f128M_to_ui64(&abs_val, softfloat_round_minMag, false);
|
||||||
bigint_normalize(dest);
|
bigint_normalize(dest);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,3 +66,9 @@ fn testDifferentSizedFloatComparisons() !void {
|
|||||||
// try expect(@nearbyint(a) == -4);
|
// try expect(@nearbyint(a) == -4);
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
test "negative f128 floatToInt at compile-time" {
|
||||||
|
const a: f128 = -2;
|
||||||
|
var b = @floatToInt(i64, a);
|
||||||
|
try expect(@as(i64, -2) == b);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user