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.

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 allclose all

Basic Examples  (4)

Find the number of decimal digits in 123456789:

The number of binary digits in :

Plot it:

The IntegerLength for different bases:

Applications  (2)

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

Wolfram Research (2007), IntegerLength, Wolfram Language function, https://reference.wolfram.com/language/ref/IntegerLength.html.

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_2024_integerlength, author="Wolfram Research", title="{IntegerLength}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/IntegerLength.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_integerlength, organization={Wolfram Research}, title={IntegerLength}, year={2007}, url={https://reference.wolfram.com/language/ref/IntegerLength.html}, note=[Accessed: 21-November-2024 ]}