IntegerLength

IntegerLength[n]
gives the number of digits in the base 10 representation of the integer n.

IntegerLength[n, b]
gives the number of digits in the base b representation of n.

DetailsDetails

  • Integer mathematical function, suitable for both symbolic and numerical manipulation.
  • IntegerLength[n, b] is effectively an efficient version of Floor[Log[b, n]]+1.
  • IntegerLength ignores the sign of n.
  • IntegerLength automatically threads over lists.

ExamplesExamplesopen allclose all

Basic Examples (4)Basic Examples (4)

Find the number of decimal digits in 123456789:

In[1]:=
Click for copyable input
Out[1]=

The number of binary digits in :

In[1]:=
Click for copyable input
Out[1]=

Plot it:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

The IntegerLength for different bases:

In[1]:=
Click for copyable input
Out[1]=
New in 6
New to Mathematica? Find your learning path »
Have a question? Ask support »