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.
IntegerLength
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.
Details
- 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. »
Examples
open all close allBasic Examples (3)
Find the number of decimal digits in 123456789:
IntegerLength[123456789]The number of binary digits in
:
IntegerLength[100!, 2]Plot the base-10 integer length over a symmetric range of positive and negative inputs:
DiscretePlot[IntegerLength[n], {n, -25, 25}, PlotMarkers -> Automatic]Scope (2)
Visualize the jumps the binary length of positive integers:
DiscretePlot[IntegerLength[n, 2], {n, 2 ^ 10 - 1}, IconizedObject[«DiscretePlot options»]]Plot the integer length for different bases:
Table[DiscretePlot[IntegerLength[n, b], {n, -25, 25}, PlotLabel -> b], {b, 2, 7}]Applications (2)
Visualize when the length of Factorial[n] becomes longer than n itself:
ListLinePlot[Table[IntegerLength[n!] - n, {n, 50}]]Find how the number of digits in
decreases with the base:
Table[IntegerLength[100!, n], {n, 2, 20}]Properties & Relations (3)
IntegerLength[n,b] is effectively an efficient version of Floor[Log[b,n]]+1:
With[{n = RandomInteger[10 ^ 6], b = RandomInteger[{2, 16}]}, IntegerLength[n, b] == Floor[Log[b, n]] + 1]IntegerLength ignores the sign of n:
With[{n = RandomInteger[10 ^ 6], b = RandomInteger[{2, 16}]}, IntegerLength[n, b] == IntegerLength[-n, b]]IntegerLength threads over lists:
IntegerLength[{1, 12, 123}]IntegerLength[100, {10, 16, 256}]Possible Issues (1)
IntegerLength considers 0 to have no digits:
IntegerLength[0, 2]DigitCount and IntegerDigits, by contrast, consider 0 to consist of a single digit:
{DigitCount[0, 10, 0], IntegerDigits[0]}Tech Notes
Related Guides
History
Introduced in 2007 (6.0)
Text
Wolfram Research (2007), IntegerLength, Wolfram Language function, https://reference.wolfram.com/language/ref/IntegerLength.html.
CMS
Wolfram Language. 2007. "IntegerLength." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/IntegerLength.html.
APA
Wolfram Language. (2007). IntegerLength. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/IntegerLength.html
BibTeX
@misc{reference.wolfram_2026_integerlength, author="Wolfram Research", title="{IntegerLength}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/IntegerLength.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_integerlength, organization={Wolfram Research}, title={IntegerLength}, year={2007}, url={https://reference.wolfram.com/language/ref/IntegerLength.html}, note=[Accessed: 12-June-2026]}