Optimize high-usage function number_of_lowest_bit

Closes issue #974.