Skip to content

NumberExpand ​

The place-value terms of nn: each digit times its power of the base.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageNumberExpand✓
NumberExpand(n)the base-10 place-value terms of nn
NumberExpand(n, base)place-value terms in the given base
NumberExpand(n, base, len)padded to len digits (leading zero terms) first
Typed signatures
TypePackageApplies
(integer, integer?, integer?) -> listnumeralsalways

Domain: Numeral systems

Details
  • The terms sum back to nn: Total(NumberExpand(n)) is nn
  • Every term carries the sign of nn, not just the leading one

Examples

Basic #
live ↗
InNumberExpand(1 234)\mathrm{NumberExpand}(1\,234)Out[1 000,200,30,4]\bigl\lbrack1\,000, 200, 30, 4\bigr\rbrack

Splits into place-value parts 100+50+7100+50+7

live ↗
InNumberExpand(157)\mathrm{NumberExpand}(157)Out[100,50,7]\bigl\lbrack100, 50, 7\bigr\rbrack

Base 2 expansion keeps zero places: 128+16+8+4+1128+16+8+4+1

live ↗
InNumberExpand(157,2)\mathrm{NumberExpand}(157, 2)Out[128,0,0,16,8,4,0,1]\bigl\lbrack128, 0, 0, 16, 8, 4, 0, 1\bigr\rbrack
live ↗
InNumberExpand(157,2,3)\mathrm{NumberExpand}(157, 2, 3)Out[128,0,29]\bigl\lbrack128, 0, 29\bigr\rbrack
Scope #

base 2, zero terms kept

live ↗
InNumberExpand(10,2)\mathrm{NumberExpand}(10, 2)Out[8,0,2,0]\bigl\lbrack8, 0, 2, 0\bigr\rbrack

every term carries the sign

live ↗
InNumberExpand(−123)\mathrm{NumberExpand}(-123)Out[−100,−20,−3]\bigl\lbrack-100, -20, -3\bigr\rbrack

Each digit scaled by its power of ten

live ↗
InNumberExpand(1 437)\mathrm{NumberExpand}(1\,437)Out[1 000,400,30,7]\bigl\lbrack1\,000, 400, 30, 7\bigr\rbrack

Negative numbers give negative parts

live ↗
InNumberExpand(−14 379)\mathrm{NumberExpand}(-14\,379)Out[−10 000,−4 000,−300,−70,−9]\bigl\lbrack-10\,000, -4\,000, -300, -70, -9\bigr\rbrack
Properties #

Each term is a digit times a place value

live ↗
InNumberExpand(1 532)\mathrm{NumberExpand}(1\,532)Out[1 000,500,30,2]\bigl\lbrack1\,000, 500, 30, 2\bigr\rbrack

Base 10 is the default

live ↗
InNumberExpand(1 532,10)\mathrm{NumberExpand}(1\,532, 10)Out[1 000,500,30,2]\bigl\lbrack1\,000, 500, 30, 2\bigr\rbrack
live ↗
InNumberExpand(1 437,10,8)\mathrm{NumberExpand}(1\,437, 10, 8)Out[1 000,400,30,7,0,0,0,0]\bigl\lbrack1\,000, 400, 30, 7, 0, 0, 0, 0\bigr\rbrack
About
Examples11
Checked againstWolfram Language 11 agree
CrosswalkWolfram Language

See also: IntegerDigits, IntegerLength