mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
Fix bigint_shl (#9305)
This commit is contained in:
parent
9086452ff9
commit
132b18e2b3
@ -1352,7 +1352,7 @@ void bigint_shl(BigInt *dest, const BigInt *op1, const BigInt *op2) {
|
||||
|
||||
if (op1->digit_count == 1 && shift_amt < 64) {
|
||||
dest->data.digit = op1_digits[0] << shift_amt;
|
||||
if (dest->data.digit > op1_digits[0]) {
|
||||
if (dest->data.digit >> shift_amt == op1_digits[0]) {
|
||||
dest->digit_count = 1;
|
||||
dest->is_negative = op1->is_negative;
|
||||
return;
|
||||
|
||||
@ -573,6 +573,13 @@ test "comptime shlWithOverflow" {
|
||||
try expect(ct_shifted == rt_shifted);
|
||||
}
|
||||
|
||||
test "comptime shl" {
|
||||
var a: u128 = 3;
|
||||
var b: u7 = 63;
|
||||
var c: u128 = 3 << 63;
|
||||
try expectEqual(a << b, c);
|
||||
}
|
||||
|
||||
test "runtime 128 bit integer division" {
|
||||
var a: u128 = 152313999999999991610955792383;
|
||||
var b: u128 = 10000000000000000000;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user