# Get the number of digits from a number

I'm looking for a function $f$ that would give me the following results :

For any $x$ such as $x \in \mathbb {N^*}, x>0$

$f(x) = 1$ when $1\leq x < 10$

$f(x) = 2$ when $10\leq x < 100$

$f(x) = 3$ when $100\leq x < 1000$

and so on ...

So far , I have tried the floor function with no success.

• Note this is fundamental to computing. To store the number 4294967295, you need $\lfloor\log_{2}(4294967295)\rfloor + 1 = 32$ bits. – BoppreH Jul 8 '13 at 15:01