I was wondering about the most effective (and fast) way to extract number of digits from an integer. I’ve come to two conclusions:
- Old while() loop (divide until digits left)
- log10 (logarithm to base 10)
Which one of these is faster? I had this doubt because I made out that the while() loop requires modulo (%) operation, which is very complex, whereas log10 is another complex math operation.