RealDigits
✖
RealDigits
gives a list of the digits in the approximate real number x, together with the number of digits that are to the left of the decimal point.
Details

- RealDigits gives the most significant digits first, as in standard positional notation.
- RealDigits[x] normally returns a list of digits of length Round[Precision[x]].
- RealDigits[x] and RealDigits[x,b] normally require that x be an approximate real number, returned for example by N. RealDigits[x,b,len] also works on exact numbers.
- For integers and rational numbers with terminating digit expansions, RealDigits[x] returns an ordinary list of digits. For rational numbers with non‐terminating digit expansions, it yields a list of the form {a1,a2,…,{b1,b2,…}} representing the digit sequence consisting of the ai followed by infinite cyclic repetitions of the bi. »
- If len is larger than Precision[x]/Log[10,b], then remaining digits are filled in as Indeterminate.
- RealDigits[x,b,len,n] starts with the digit which is the coefficient of bn, truncating or padding with zeros as necessary. »
- RealDigits[x,b,len,-1] starts with the digit immediately to the right of the base‐b decimal point in x.
- RealDigits[x,b,Automatic,n] gives as many digits as it can in a fixed-precision number.
- The base b in RealDigits[x,b] need not be an integer. For any real b such that b>1, RealDigits[x,b] successively finds the largest integer multiples of powers of b that can be removed while leaving a non‐negative remainder.
- RealDigits[x] discards the sign of x.
- RealDigits[0.] gives {{0},-Floor[Accuracy[0.]]}.
- FromDigits can be used as the inverse of RealDigits.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Give the list of digits and exponent:

https://wolfram.com/xid/0bdpp9kq6-m3r


https://wolfram.com/xid/0bdpp9kq6-cfd


https://wolfram.com/xid/0bdpp9kq6-uu7


https://wolfram.com/xid/0bdpp9kq6-e0i

Give an explicit recurring decimal form:

https://wolfram.com/xid/0bdpp9kq6-t5e

Scope (3)Survey of the scope of standard use cases

https://wolfram.com/xid/0bdpp9kq6-wd5


https://wolfram.com/xid/0bdpp9kq6-jan

20 digits starting with the coefficient of :

https://wolfram.com/xid/0bdpp9kq6-mof

20 digits starting with the coefficient of :

https://wolfram.com/xid/0bdpp9kq6-yyg


https://wolfram.com/xid/0bdpp9kq6-e9

Generalizations & Extensions (2)Generalized and extended use cases
RealDigits gives Indeterminate if more digits than the precision are requested:

https://wolfram.com/xid/0bdpp9kq6-ky7lli


https://wolfram.com/xid/0bdpp9kq6-bgib90

Include only digits that are determined by the precision available:

https://wolfram.com/xid/0bdpp9kq6-fgrkxp

Applications (6)Sample problems that can be solved with this function

https://wolfram.com/xid/0bdpp9kq6-w3o

Number of 1s in the first million base-2 digits of :

https://wolfram.com/xid/0bdpp9kq6-pge

Distribution of first 100000 digits of in base 47:

https://wolfram.com/xid/0bdpp9kq6-c6pzme

Fibonacci representations of integers:

https://wolfram.com/xid/0bdpp9kq6-l5u

Binary representation of a machine number:

https://wolfram.com/xid/0bdpp9kq6-co587u


https://wolfram.com/xid/0bdpp9kq6-bbvkja

is equal to the number of bits times
:

https://wolfram.com/xid/0bdpp9kq6-evwl7o

Get the next larger machine number:

https://wolfram.com/xid/0bdpp9kq6-ecjdda

The spacing between these numbers is 2(e-1) $MachineEpsilon:

https://wolfram.com/xid/0bdpp9kq6-ga784

Find the error in representing 1/10 with a machine number:

https://wolfram.com/xid/0bdpp9kq6-c4lnzw


https://wolfram.com/xid/0bdpp9kq6-ivlpsc


https://wolfram.com/xid/0bdpp9kq6-k0835p

The next smaller machine number is farther away:

https://wolfram.com/xid/0bdpp9kq6-b4uuy6

Properties & Relations (1)Properties of the function, and connections to other functions
Possible Issues (2)Common pitfalls and unexpected behavior
Digits unknown at the available precision are filled in as Indeterminate:

https://wolfram.com/xid/0bdpp9kq6-ka5

For non-binary bases, the digits given may not be enough to reconstruct the number exactly:

https://wolfram.com/xid/0bdpp9kq6-c5m99n

More than Round[MachinePrecision] decimal digits are required to separate x from 1:

https://wolfram.com/xid/0bdpp9kq6-gs29vu

InputForm uses a sufficient number of digits to uniquely reconstruct the number:

https://wolfram.com/xid/0bdpp9kq6-0f92l


https://wolfram.com/xid/0bdpp9kq6-cm9vty

Wolfram Research (1991), RealDigits, Wolfram Language function, https://reference.wolfram.com/language/ref/RealDigits.html (updated 2007).
Text
Wolfram Research (1991), RealDigits, Wolfram Language function, https://reference.wolfram.com/language/ref/RealDigits.html (updated 2007).
Wolfram Research (1991), RealDigits, Wolfram Language function, https://reference.wolfram.com/language/ref/RealDigits.html (updated 2007).
CMS
Wolfram Language. 1991. "RealDigits." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/RealDigits.html.
Wolfram Language. 1991. "RealDigits." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/RealDigits.html.
APA
Wolfram Language. (1991). RealDigits. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RealDigits.html
Wolfram Language. (1991). RealDigits. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RealDigits.html
BibTeX
@misc{reference.wolfram_2025_realdigits, author="Wolfram Research", title="{RealDigits}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/RealDigits.html}", note=[Accessed: 13-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_realdigits, organization={Wolfram Research}, title={RealDigits}, year={2007}, url={https://reference.wolfram.com/language/ref/RealDigits.html}, note=[Accessed: 13-April-2025
]}