diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-08-17 17:14:35 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-08-17 17:14:35 -0400 |
| commit | 0d117bb0a993b2a0a290f99255c5bf1bf05f187f (patch) | |
| tree | 54abbc90bb6c31746eb0d9b1c8a3269395190900 /src/bigint.cpp | |
| parent | 6a98bf3dba6f3ed5b40fe7899899e2a792028be4 (diff) | |
| download | zig-0d117bb0a993b2a0a290f99255c5bf1bf05f187f.tar.gz zig-0d117bb0a993b2a0a290f99255c5bf1bf05f187f.zip | |
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
Diffstat (limited to 'src/bigint.cpp')
| -rw-r--r-- | src/bigint.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bigint.cpp b/src/bigint.cpp index 5679d2041a..5c68b18a81 100644 --- a/src/bigint.cpp +++ b/src/bigint.cpp @@ -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]; |
