NumberDigit[x,n]
returns the digit corresponding to 10n in the real-valued number x.
NumberDigit[x,n,b]
returns the digit corresponding to b
.
NumberDigit
NumberDigit[x,n]
returns the digit corresponding to 10n in the real-valued number x.
NumberDigit[x,n,b]
returns the digit corresponding to b
.
Details
- The digit to the immediate left of the decimal point is the

digit. - In NumberDigit[x,…], x can be any real-valued numeric expression.
- NumberDigit[x,{n1,n2,…}] returns {NumberDigit[x,n1],NumberDigit[x,n2],…}.
- In NumberDigit[x,n,b], the base b must be a real-valued number greater than 1.
- NumberDigit is listable in its first argument.
Examples
open all close allBasic Examples (2)
Scope (7)
Find the 104 and 106 digits of a number:
NumberDigit[123456789, {4, 6}]Find the 103, 105 and 107 digits in a number:
NumberDigit[9876543210, Range[3, 7, 2]]Find the 102 through 10-2 digits of Pi:
NumberDigit[Pi, Range[2, -2, -1]]Find the 102 through 10-2 digits of Pi in base 16:
NumberDigit[Pi, Range[2, -2, -1], 16]Find the first three digits of the fraction (2/3)
NumberDigit[2 / 3, Range[-1, -3, -1]]Digits of negative numbers are the same as for their positive counterparts:
NumberDigit[-123456789, {2, 4, 6}]The base need not be an integer, and you can find the first several digits of Pi to a base strictly between 1 and 2:
NumberDigit[Pi, Range[2, -4, -1], GoldenRatio]These are not the same as the digits to corresponding powers in base 2:
NumberDigit[Pi, Range[2, -4, -1], 2]NumberDigit is listable in its first argument:
NumberDigit[{Pi, E, 99352, 11 / 7}, {4, 0, -2}]Applications (2)
Show that the fourth digit of random reals between 0 and 1 is equally distributed over the range from 0 through 9:
Histogram[NumberDigit[RandomReal[1, 10000], -4]]Take all days of the year 2021:
dates = DateRange[{2021, 1, 1}, {2021, 12, 31}];Histogram of the ![]()
digits of months:
Histogram[NumberDigit[dates[[All, 2]], 0]]Histogram of the ![]()
digits of days:
Histogram[NumberDigit[dates[[All, 3]], 0]]Histogram of the ![]()
digits of days:
Histogram[NumberDigit[dates[[All, 3]], 1]]Properties & Relations (1)
NumberDigit[x,n,b] returns the digit given as the first element of RealDigits[x,b,1,n]:
NumberDigit[Sqrt[20], -5, 10]First@RealDigits[Sqrt[20], 10, 1, -5]Possible Issues (1)
Neat Examples (1)
Take a thousand sums of a hundred reals between 0 and 1:
sums = Total /@ RandomReal[1, {1000, 100}];They are distributed around 50:
Histogram[sums]Around[sums]Because the deviation is smaller than 10, there is a nonuniform distribution of ![]()
digits:
Histogram[NumberDigit[sums, 0]]Related Guides
History
Text
Wolfram Research (2021), NumberDigit, Wolfram Language function, https://reference.wolfram.com/language/ref/NumberDigit.html.
CMS
Wolfram Language. 2021. "NumberDigit." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NumberDigit.html.
APA
Wolfram Language. (2021). NumberDigit. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NumberDigit.html
BibTeX
@misc{reference.wolfram_2026_numberdigit, author="Wolfram Research", title="{NumberDigit}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/NumberDigit.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_numberdigit, organization={Wolfram Research}, title={NumberDigit}, year={2021}, url={https://reference.wolfram.com/language/ref/NumberDigit.html}, note=[Accessed: 12-June-2026]}