({{, (RefLink[NumberExpand, paclet:ref/NumberExpand])[x] 
gives a list of the decimal digits of x multiplied by their corresponding powers of 10. }, {, (RefLink[NumberExpand, paclet:ref/NumberExpand])[x,b]
expands x in base b.}, {, (RefLink[NumberExpand, paclet:ref/NumberExpand])[x,b,len]
gives a list of length len.}})

OpenersNotesSection(Spacer1)Details

For any number x, (RefLink[Total, paclet:ref/Total])[NumberExpand[x,…]]==x.

For an integer x, (RefLink[NumberExpand, paclet:ref/NumberExpand])[x] returns a list of integers.

For a rational x, the fractional part of x is added to the last element of (RefLink[NumberExpand, paclet:ref/NumberExpand])[(RefLink[IntegerPart, paclet:ref/IntegerPart])[x]].

For a non-exact number x, all elements of (RefLink[NumberExpand, paclet:ref/NumberExpand])[x] but the last are exact.

For an exact number x, the length of (RefLink[NumberExpand, paclet:ref/NumberExpand])[x] equals the number of digits in the integer part of x.

For a non-exact number x, (RefLink[NumberExpand, paclet:ref/NumberExpand])[x] normally returns a list of length (RefLink[Round, paclet:ref/Round])[(RefLink[Precision, paclet:ref/Precision])[x]].

For a non-exact number x and an exact base b, (RefLink[NumberExpand, paclet:ref/NumberExpand])[x,b] normally returns a list of length (RefLink[Round, paclet:ref/Round])[(RefLink[Precision, paclet:ref/Precision])[x] (RefLink[Log, paclet:ref/Log])[b,10]].

If len is larger than (RefLink[Precision, paclet:ref/Precision])[x] (RefLink[Log, paclet:ref/Log])[b,10], the remaining parts of the expansion are filled in as (RefLink[Indeterminate, paclet:ref/Indeterminate]).

The base b in (RefLink[NumberExpand, paclet:ref/NumberExpand])[x,b] can be a real number greater than 1.

For any number x of absolute value less than 1, the first element of (RefLink[NumberExpand, paclet:ref/NumberExpand])[x,…] is 0 or 0..

(RefLink[NumberExpand, paclet:ref/NumberExpand])[0.] returns a list of length (RefLink[Floor, paclet:ref/Floor])[(RefLink[Accuracy, paclet:ref/Accuracy])[0.]]+2.

OpenersPrimaryExamplesSection(Spacer1)Examples  (23)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Expand a number into a list of multiples of powers of 10:

NumberExpand[157]

Total[%]

Expand a number in base 2:

NumberExpand[157,2]

Total[%]

Specify the length of the output:

NumberExpand[157,2,3]

Total[%]

OpenersExampleSection1(Spacer1)Scope  (5)

Expand an integer into a list of multiples of powers of 10:

NumberExpand[1437]

Total[%]

Expand a rational number in base 2, obtaining a rational remaining part:

NumberExpand[1111/7,2]

Total[%]

Expand a machine-precision real number, obtaining a machine-precision remaining part:

NumberExpand[1234.56]

Total[%]

Expand an exact complex number in base 7:

NumberExpand[123+9I,7]

Total[%]

Expand an inexact complex number in base 10:

NumberExpand[1.2+0.4I,10]

Total[%]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (5)

Expand a negative integer:

NumberExpand[-14379]

Total[%]

Expand a real number in a rational base:

NumberExpand[1.23,7/2,10]

Total[%]

Expand a number using a machine-precision base:

NumberExpand[9,6.5]

Total[%]

Expand a rational number in a real base:

NumberExpand[1111/7,7.5,8]

Total[%]
%===N[1111/7]

Expand a real number in a real base:

NumberExpand[1.23,3.5,10]

Total[%]

OpenersExampleSection4(Spacer1)Properties & Relations  (9)

For an integer, when the length of the output is required to be larger than needed, (RefLink[NumberExpand, paclet:ref/NumberExpand]) pads with 0s on the right:

NumberExpand[1437,10,8]

For a rational number with a finite-length decimal part, when the length of the output is required to be larger than needed, (RefLink[NumberExpand, paclet:ref/NumberExpand]) pads with 0s on the right:

NumberExpand[1111/2,10,9]

For a rational number with an infinite-length decimal part, the last element of the output list is always nonzero:

n=10993/7000;
NumberExpand[n,10,4]

NumberExpand[n,10,5]

For any number n, (RefLink[Total, paclet:ref/Total])[NumberExpand[n,…]] equals n:

n=63;
Total[NumberExpand[n]]==n

n=27.`19;
Total[NumberExpand[n,8,5]]==n

The total of the expansion of an exact number in an integer base is the number itself:

NumberExpand[1532]

Total[%]

If the base is non-exact, the total will have a different precision:

NumberExpand[1532,10.]

Total[%]

For an exact number expanded into inexact parts, the difference with the total is smaller than the last part of the expansion:

n=22/3;
expansion=NumberExpand[n,7.5,8]

total=Total[expansion]

n-total<Last[expansion]

Then (RefLink[Rationalize, paclet:ref/Rationalize]) may be able to recover the original exact number:

Rationalize[total,Last[expansion]]

When a non-exact number is expanded in an exact base, all the elements of the output list but the last are exact:

NumberExpand[9.738,10]

The last element is not necessarily zero:

NumberExpand[9.739,10]

For non-exact numbers, (RefLink[NumberExpand, paclet:ref/NumberExpand]) returns a list of parts corresponding to the digits of (RefLink[RealDigits, paclet:ref/RealDigits]):

NumberExpand[79.7377]

First[RealDigits[79.7377]]

Small variations of the input may result in representations containing multiple 9s:

NumberExpand[79.7378]

First[RealDigits[79.7378]]

The precision of (RefLink[Total, paclet:ref/Total])[NumberExpand[…]] is effectively determined by the minimum precision of the input arguments:

n=12.345;base=10;
expansion=NumberExpand[n,base,5]

{Precision[n],Precision[base],Precision[Total[expansion]]}

n=N[Pi,40];base=10`20;
expansion=NumberExpand[n,base,5]

{Precision[n],Precision[base],Precision[Total[expansion]]}

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

NumberExpand[{23,5/2},{5,2.5},{3,8}]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

Parts of the expansion unknown at the available precision are filled in as (RefLink[Indeterminate, paclet:ref/Indeterminate]):

n=1.234;
NumberExpand[n,10]

NumberExpand[n,10,18]

In this situation, the original number cannot be reconstructed:

Total[%]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[IntegerDigits, paclet:ref/IntegerDigits])  ▪  (RefLink[RealDigits, paclet:ref/RealDigits])  ▪  (RefLink[NumberDecompose, paclet:ref/NumberDecompose])}})}})

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