aboutsummaryrefslogtreecommitdiff
path: root/src/bigint.cpp
diff options
context:
space:
mode:
authorJimmi Holst Christensen <jhc@liab.dk>2018-01-17 14:31:47 +0100
committerJimmi Holst Christensen <jhc@liab.dk>2018-01-17 14:31:47 +0100
commitfa2c3be341ac6a7eddc65397984dac1bf648be26 (patch)
treef389038e0324fad415aa6a80096ebb5328f86950 /src/bigint.cpp
parentdb0fc32ab2d5277655a87200be8f602473ed30d2 (diff)
downloadzig-fa2c3be341ac6a7eddc65397984dac1bf648be26.tar.gz
zig-fa2c3be341ac6a7eddc65397984dac1bf648be26.zip
More tests, and fixed none negative bigint xor
Diffstat (limited to 'src/bigint.cpp')
-rw-r--r--src/bigint.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bigint.cpp b/src/bigint.cpp
index 05c6463aa3..85e5dad4ad 100644
--- a/src/bigint.cpp
+++ b/src/bigint.cpp
@@ -1295,14 +1295,16 @@ void bigint_xor(BigInt *dest, const BigInt *op1, const BigInt *op2) {
dest->is_negative = false;
const uint64_t *op1_digits = bigint_ptr(op1);
const uint64_t *op2_digits = bigint_ptr(op2);
+
+ assert(op1->digit_count > 0 && op2->digit_count > 0);
+ uint64_t first_digit = op1_digits[0] ^ op2_digits[0];
if (op1->digit_count == 1 && op2->digit_count == 1) {
dest->digit_count = 1;
- dest->data.digit = op1_digits[0] ^ op2_digits[0];
+ dest->data.digit = first_digit;
bigint_normalize(dest);
return;
}
// TODO this code path is untested
- uint64_t first_digit = dest->data.digit;
dest->digit_count = max(op1->digit_count, op2->digit_count);
dest->data.digits = allocate_nonzero<uint64_t>(dest->digit_count);
dest->data.digits[0] = first_digit;