Closed saxbophone closed 1 year ago
Found useful optimisations to be applied here when checking if a single digit is a power of 2 and for log2(): http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious
This optimisation should also probably be applied to Nat.bit_length()
Extension task:
where $countbits()$ just counts the number of bits to the right of the highest bit set, including the highest bit set.
Logarithms are very useful for underpinning other mathematical operations so this optimisation may be very useful.