replace math.log with bitwise operation