NumberDecompose[x,{u1,…,un}]
returns a list of coefficients {c1,…,cn} of a decomposition of the number x in the basis {u1,…,un}.
NumberDecompose
NumberDecompose[x,{u1,…,un}]
returns a list of coefficients {c1,…,cn} of a decomposition of the number x in the basis {u1,…,un}.
Details
- The basis {u1,…,un} must be a list of nonincreasing positive numbers.
- The result has the same length of the basis, even if the initial coefficients are zero.
- The coefficients {c1,…,cn-1} are integers, but cn will be exact or not depending on the precision of x and the basis elements.
- NumberDecompose[x,units] for negative x is equivalent to -NumberDecompose[-x,units].
Examples
open all close allBasic Examples (2)
Scope (3)
Decompose an exact number using a basis of exact numbers:
NumberDecompose[99, {10, 5, 2, 1}]NumberDecompose[99 / 2, {10, 5, 2, 1}]Decompose an exact numeric quantity using an exact basis:
NumberDecompose[10Pi, {E, 1}]NumberDecompose[N[10Pi], {E, 1}]NumberDecompose[10Pi, {E, 1.}]NumberDecompose[-99, {10, 5, 2, 1}]This is equivalent to the negative of the decomposition of its absolute value:
-NumberDecompose[99, {10, 5, 2, 1}]Applications (2)
Decompose an amount of United States dollars in the available banknote denominations:
denominations = {100, 50, 20, 10, 5, 2, 1};NumberDecompose[672, denominations]Decompose an amount of Bahamian dollars in the available banknote denominations:
denominations = {100, 50, 20, 10, 5, 3, 2, 1, 1 / 2};NumberDecompose[598.50, denominations]Properties & Relations (7)
The result of NumberDecompose is a list of non-negative numbers for a positive input:
NumberDecompose[598.32, {100, 50, 20, 10, 5, 2, 1}]The result is a list of nonpositive numbers for a negative input:
NumberDecompose[-598.32, {100, 50, 20, 10, 5, 2, 1}]NumberCompose is the inverse of NumberDecompose:
units = {86400, 3600, 60, 1}NumberDecompose[513134, units]NumberCompose[%, units]DMSList is a special case of NumberDecompose:
DMSList[24.6254]NumberDecompose[24.6254, {1, 1 / 60, 1 / 3600}]The length of the result equals the length of the basis:
NumberDecompose[13, {5, 1}]NumberDecompose[13, {1}]NumberDecompose[13, {}]For integers, NumberDecompose returns the last solution found by FrobeniusSolve:
FrobeniusSolve[{5, 2, 1}, 17]Last[%] == NumberDecompose[17, {5, 2, 1}]IntegerDigits is equivalent to NumberDecompose for an adequate choice of basis of units:
IntegerDigits[54321, 10, 7]units = PowerRange[10 ^ 6, 1, 1 / 10]NumberDecompose[54321, units]IntegerDigits with a MixedRadix specification performs a NumberDecompose operation:
IntegerDigits[10 ^ 4, MixedRadix[{24, 60, 60}]]NumberDecompose[10 ^ 4, {60 60, 60, 1}]Related Guides
History
Text
Wolfram Research (2015), NumberDecompose, Wolfram Language function, https://reference.wolfram.com/language/ref/NumberDecompose.html.
CMS
Wolfram Language. 2015. "NumberDecompose." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NumberDecompose.html.
APA
Wolfram Language. (2015). NumberDecompose. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NumberDecompose.html
BibTeX
@misc{reference.wolfram_2026_numberdecompose, author="Wolfram Research", title="{NumberDecompose}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/NumberDecompose.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_numberdecompose, organization={Wolfram Research}, title={NumberDecompose}, year={2015}, url={https://reference.wolfram.com/language/ref/NumberDecompose.html}, note=[Accessed: 13-June-2026]}