| author | |
| committer | |
| log | 132b18e2b39feca3b90b1b13df2b4649b1661fd5 |
| tree | 12fdd08a6b571f29be3555f8350e53a73da60a1e |
| parent | 9086452ff98cf0ec271f449d0824d5b070b26f45 |
| signature |
2 files changed, 8 insertions(+), 1 deletions(-)
src/stage1/bigint.cpp+1-1| ... | @@ -1352,7 +1352,7 @@ void bigint_shl(BigInt *dest, const BigInt *op1, const BigInt *op2) { | ... | @@ -1352,7 +1352,7 @@ void bigint_shl(BigInt *dest, const BigInt *op1, const BigInt *op2) { |
| 1352 | 1352 | ||
| 1353 | if (op1->digit_count == 1 && shift_amt < 64) { | 1353 | if (op1->digit_count == 1 && shift_amt < 64) { |
| 1354 | dest->data.digit = op1_digits[0] << shift_amt; | 1354 | dest->data.digit = op1_digits[0] << shift_amt; |
| 1355 | if (dest->data.digit > op1_digits[0]) { | 1355 | if (dest->data.digit >> shift_amt == op1_digits[0]) { |
| 1356 | dest->digit_count = 1; | 1356 | dest->digit_count = 1; |
| 1357 | dest->is_negative = op1->is_negative; | 1357 | dest->is_negative = op1->is_negative; |
| 1358 | return; | 1358 | return; |
test/behavior/eval.zig+7| ... | @@ -573,6 +573,13 @@ test "comptime shlWithOverflow" { | ... | @@ -573,6 +573,13 @@ test "comptime shlWithOverflow" { |
| 573 | try expect(ct_shifted == rt_shifted); | 573 | try expect(ct_shifted == rt_shifted); |
| 574 | } | 574 | } |
| 575 | 575 | ||
| 576 | test "comptime shl" { | ||
| 577 | var a: u128 = 3; | ||
| 578 | var b: u7 = 63; | ||
| 579 | var c: u128 = 3 << 63; | ||
| 580 | try expectEqual(a << b, c); | ||
| 581 | } | ||
| 582 | |||
| 576 | test "runtime 128 bit integer division" { | 583 | test "runtime 128 bit integer division" { |
| 577 | var a: u128 = 152313999999999991610955792383; | 584 | var a: u128 = 152313999999999991610955792383; |
| 578 | var b: u128 = 10000000000000000000; | 585 | var b: u128 = 10000000000000000000; |