fix wrong value for clz, ctz at compile time

closes #418

also make clz, ctz return smaller integer bit widths
and use smaller integer bit widths for enum tag types
This commit is contained in:
Andrew Kelley
2017-08-17 17:14:35 -04:00
parent 6a98bf3dba
commit 0d117bb0a9
6 changed files with 30 additions and 20 deletions

View File

@@ -95,7 +95,9 @@ static void to_twos_complement(BigInt *dest, const BigInt *op, size_t bit_count)
}
static bool bit_at_index(const BigInt *bi, size_t index) {
size_t digit_index = bi->digit_count - (index / 64) - 1;
size_t digit_index = index / 64;
if (digit_index >= bi->digit_count)
return false;
size_t digit_bit_index = index % 64;
const uint64_t *digits = bigint_ptr(bi);
uint64_t digit = digits[digit_index];