fix comptime bitwise operations with negative values

closes #1387
closes #1529
This commit is contained in:
Andrew Kelley
2018-09-24 14:37:55 -04:00
parent 422269ea6e
commit 32c91ad892
2 changed files with 14 additions and 1 deletions

View File

@@ -50,7 +50,7 @@ size_t bigint_bits_needed(const BigInt *op) {
size_t full_bits = op->digit_count * 64;
size_t leading_zero_count = bigint_clz(op, full_bits);
size_t bits_needed = full_bits - leading_zero_count;
return bits_needed + op->is_negative;
return bits_needed;
}
static void to_twos_complement(BigInt *dest, const BigInt *op, size_t bit_count) {