authorgravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2018-05-10 22:26:26+12:00
committergravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2018-05-10 22:26:26+12:00
logefa39c5343e13a13e65210f55da5df23ee3feb3e
tree5bf359499baa56f4066165c135e382d3a9bb1f1e
parentc3ddf5069e0fb0b728ce275410988ccec3ab7ce9

Fix bigint shift-right partial shift


2 files changed, 9 insertions(+), 1 deletions(-)

src/bigint.cpp+1-1
......@@ -1425,7 +1425,7 @@ void bigint_shr(BigInt *dest, const BigInt *op1, const BigInt *op2) {
14251425 uint64_t digit = op1_digits[op_digit_index];
14261426 size_t dest_digit_index = op_digit_index - digit_shift_count;
14271427 dest->data.digits[dest_digit_index] = carry | (digit >> leftover_shift_count);
1428 carry = digit << leftover_shift_count;
1428 carry = digit << (64 - leftover_shift_count);
14291429
14301430 if (dest_digit_index == 0) { break; }
14311431 op_digit_index -= 1;
test/cases/math.zig+8
......@@ -366,6 +366,14 @@ test "big number multi-limb shift and mask" {
366366 }
367367}
368368
369test "big number multi-limb partial shift right" {
370 comptime {
371 var a = 0x1ffffffffeeeeeeee;
372 a >>= 16;
373 assert(a == 0x1ffffffffeeee);
374 }
375}
376
369377test "xor" {
370378 test_xor();
371379 comptime test_xor();