replace log2_int with bitwise ops