When doing order of magnitude calculations, I think that it is far more common to round the value rather than to floor it. 985 is closer to 1000 than 100, so it should be three orders of magnitude, not two.
But putting that issue aside:
Being delicate and complicated is an argument in favour of doing it right in the stdlib.
The naive algorithm by Marco is sometimes wrong, even for exact powers of ten:
def order(x):
if x == 0: return 0
return math.floor(math.log10(abs(x)))
print([i for i in range(1, 100001) if order(10**i) != i])
Output is: [512, 1024, 2048, 32768, 65536]
For one less than an exact powers of ten it is frequently wrong. Note the change in comparison â the following shows the few times it is correct:
print([i for i in range(1, 100001) if order(10**i - 1) == i-1])
Giving results: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 512, 1024, 2048, 32768, 65536]
Unfortunately Stackoverflow gives only the naive algorithm.