({{, (RefLink[IntegerLength, paclet:ref/IntegerLength])[n] 
gives the number of digits in the base 10 representation of the integer n.}, {, (RefLink[IntegerLength, paclet:ref/IntegerLength])[n,b]
gives the number of digits in the base b representation of n.}})

OpenersNotesSection(Spacer1)Details

Integer mathematical function, suitable for both symbolic and numerical manipulation.

(RefLink[IntegerLength, paclet:ref/IntegerLength])[n,b] is effectively an efficient version of (RefLink[Floor, paclet:ref/Floor])[(RefLink[Log, paclet:ref/Log])[b,n]]+1.

(RefLink[IntegerLength, paclet:ref/IntegerLength]) ignores the sign of n.

(RefLink[IntegerLength, paclet:ref/IntegerLength]) automatically threads over lists.

OpenersPrimaryExamplesSection(Spacer1)Examples  (6)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Find the number of decimal digits in 123456789:

IntegerLength[123456789]

The number of binary digits in 100!:

IntegerLength[100!,2]

Plot it:

DiscretePlot[IntegerLength[n],{n,-25,25}]

DiscretePlot[IntegerLength[n,2],{n,2^10-1}]

The (RefLink[IntegerLength, paclet:ref/IntegerLength]) for different bases:

Table[DiscretePlot[IntegerLength[n,b],{n,-25,25},PlotLabel->b],{b,2,7}]

OpenersExampleSection2(Spacer1)Applications  (2)

ListLinePlot[Table[IntegerLength[n!]-n,{n,50}]]

Find how the number of digits in 100! decreases with the base:

Table[IntegerLength[100!,n],{n,2,20}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Log10, paclet:ref/Log10])  ▪  (RefLink[Log2, paclet:ref/Log2])  ▪  (RefLink[Log, paclet:ref/Log])  ▪  (RefLink[DigitCount, paclet:ref/DigitCount])  ▪  (RefLink[IntegerDigits, paclet:ref/IntegerDigits])  ▪  (RefLink[BitLength, paclet:ref/BitLength])  ▪  (RefLink[ByteCount, paclet:ref/ByteCount])  ▪  (RefLink[IntegerExponent, paclet:ref/IntegerExponent])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Digits in Numbers, paclet:tutorial/DigitsInNumbers])}, {▪(RefLinkPlain[Integer and Number Theoretic Functions, paclet:tutorial/IntegerAndNumberTheoreticalFunctions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Representation of Numbers, paclet:guide/RepresentationOfNumbers])}, {▪(RefLinkPlain[Number Digits, paclet:guide/NumberDigits])}, {▪(RefLinkPlain[Integer Functions, paclet:guide/IntegerFunctions])}})}})