mirror of
https://github.com/ziglang/zig.git
synced 2025-12-15 18:53:07 +00:00
Fix bigint shift-right partial shift
This commit is contained in:
parent
c3ddf5069e
commit
efa39c5343
@ -1425,7 +1425,7 @@ void bigint_shr(BigInt *dest, const BigInt *op1, const BigInt *op2) {
|
|||||||
uint64_t digit = op1_digits[op_digit_index];
|
uint64_t digit = op1_digits[op_digit_index];
|
||||||
size_t dest_digit_index = op_digit_index - digit_shift_count;
|
size_t dest_digit_index = op_digit_index - digit_shift_count;
|
||||||
dest->data.digits[dest_digit_index] = carry | (digit >> leftover_shift_count);
|
dest->data.digits[dest_digit_index] = carry | (digit >> leftover_shift_count);
|
||||||
carry = digit << leftover_shift_count;
|
carry = digit << (64 - leftover_shift_count);
|
||||||
|
|
||||||
if (dest_digit_index == 0) { break; }
|
if (dest_digit_index == 0) { break; }
|
||||||
op_digit_index -= 1;
|
op_digit_index -= 1;
|
||||||
|
|||||||
@ -366,6 +366,14 @@ test "big number multi-limb shift and mask" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "big number multi-limb partial shift right" {
|
||||||
|
comptime {
|
||||||
|
var a = 0x1ffffffffeeeeeeee;
|
||||||
|
a >>= 16;
|
||||||
|
assert(a == 0x1ffffffffeeee);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test "xor" {
|
test "xor" {
|
||||||
test_xor();
|
test_xor();
|
||||||
comptime test_xor();
|
comptime test_xor();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user