Why count digits?

Counting the digits in a number looks simple until the edges arrive. Negative values, zero, and very large numbers each ask a slightly different question of the implementation.

An arithmetic approach keeps the operation numeric and compact. A string-based approach is often easier to read and makes the intent visible at a glance. The right choice depends on whether the code is teaching an idea, handling input, or sitting on a hot path.

The useful part is not choosing one method forever. It is knowing what each method assumes before the camera starts rolling on the next problem.