Improve the log2 calculation routine.