| author | |
| committer | |
| log | 1063bf696ed27d58d0c869f7b1f663a6c68b68c1 |
| tree | ff6e348f8c51d91a849839966e88564a3add1694 |
| parent | 3b8c4f07a4a83a31f9d863dd6410332982be1c1e |
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| ... | @@ -570,6 +570,13 @@ test "comptime shlWithOverflow" { | ... | @@ -570,6 +570,13 @@ test "comptime shlWithOverflow" { |
| 570 | try expect(ct_shifted == rt_shifted); | 570 | try expect(ct_shifted == rt_shifted); |
| 571 | } | 571 | } |
| 572 | 572 | ||
| 573 | test "comptime shl" { | ||
| 574 | var a: u128 = 3; | ||
| 575 | var b: u7 = 63; | ||
| 576 | var c: u128 = 3 << 63; | ||
| 577 | try expectEqual(a << b, c); | ||
| 578 | } | ||
| 579 | |||
| 573 | test "runtime 128 bit integer division" { | 580 | test "runtime 128 bit integer division" { |
| 574 | var a: u128 = 152313999999999991610955792383; | 581 | var a: u128 = 152313999999999991610955792383; |
| 575 | var b: u128 = 10000000000000000000; | 582 | var b: u128 = 10000000000000000000; |