aboutsummaryrefslogtreecommitdiff
path: root/src/bigint.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-05-09 23:43:07 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-05-09 23:43:07 -0400
commit6928badd850f9fcebdcc0b13287db2c81d2293c0 (patch)
tree241e9cbce7646b6ca7a0b0287a9a76dd14a4f38e /src/bigint.cpp
parentac4d55dec1e32ddef945bfa246eb78f20f31ec44 (diff)
parentbf21747a426887ed2ac866c9a9d317f64b22da79 (diff)
downloadzig-6928badd850f9fcebdcc0b13287db2c81d2293c0.tar.gz
zig-6928badd850f9fcebdcc0b13287db2c81d2293c0.zip
Merge branch 'master' into pointer-reform
Diffstat (limited to 'src/bigint.cpp')
-rw-r--r--src/bigint.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/bigint.cpp b/src/bigint.cpp
index 2a688debd5..64bc59e5cf 100644
--- a/src/bigint.cpp
+++ b/src/bigint.cpp
@@ -1259,12 +1259,11 @@ void bigint_and(BigInt *dest, const BigInt *op1, const BigInt *op2) {
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;
- size_t i = 1;
+
+ size_t i = 0;
for (; i < op1->digit_count && i < op2->digit_count; i += 1) {
dest->data.digits[i] = op1_digits[i] & op2_digits[i];
}
@@ -1412,7 +1411,6 @@ void bigint_shr(BigInt *dest, const BigInt *op1, const BigInt *op2) {
return;
}
- // TODO this code path is untested
size_t digit_shift_count = shift_amt / 64;
size_t leftover_shift_count = shift_amt % 64;
@@ -1427,7 +1425,7 @@ void bigint_shr(BigInt *dest, const BigInt *op1, const BigInt *op2) {
uint64_t digit = op1_digits[op_digit_index];
size_t dest_digit_index = op_digit_index - digit_shift_count;
dest->data.digits[dest_digit_index] = carry | (digit >> leftover_shift_count);
- carry = (0xffffffffffffffffULL << leftover_shift_count) & digit;
+ carry = digit << leftover_shift_count;
if (dest_digit_index == 0) { break; }
op_digit_index -= 1;