Parameters that arise for me;
Brute force: keep the integer division by 10 until you get zero; (e.g. 860 takes 3 shifts (86, 8, 0), so it's 10 ^ 3) and then returns n / (order 10 ^)
Binary search: as you say, search by degrees 10, but this requires additional variables and assignments, and the problem will be that the additional tracking information is paid by the type of numbers you care about? For example, if most of your numbers are small, brute force can only be faster.
Bitshift Optimization: Counts how many times you need to do x >> 1 until you reach zero; This sets the range for your search. For example, 94 takes 7 shifts to clear the number. Therefore, 128. Therefore, start the search for brute force at 10 ^ 3. You will need to search for the order of bits =>.
source share