Question: What powers of 10 is a number? ... almost

I was trying to find the best way to determine what powers of 10 a number is. 

trunc(log10(a)) #a being any number

It works great for integers, however it fails when the number has is some integer with 7 nine's in the decimal.
trunc(log10(99.999999))
                                                  1

trunc(log10(99.9999998))
                                                 1

trunc(log10(99.9999999))
                                                 2

To get around that fail I found length to be another way. 
     length(trunc(a))-1  #a is any number

Any other ways or mayber there's a better way?

Please Wait...