Skip to content

AdicExpansion ​

The digits of a bb-adic number, written with the infinite end on the left: …6667\ldots 6667 for 1/31/3 in Z10\mathbb{Z}_{10}, 0.120.12 for 7/257/25 in Q5\mathbb{Q}_5, +O(bn)+ O(b^n) when capped.

AdicExpansion(x, count?)the first count digits (default 20) as a string
AdicDigits(x, count?)the same digits as a list, LEAST significant first — the only order that lists something with no left end
Typed signatures
TypePackageApplies
(value, integer?) -> stringnumeralsalways

Domain: Numeral systems

Details
  • The ellipsis marks the infinite left end and is dropped only when nothing hides there: an exact non-negative integer (times bvb^v)
  • Digits past the point are the negative-valuation places, prime bases only
  • Digits ≥10\ge 10 are bracketed, so base 16 reads …[15][15][15]

Examples

Basic #
live ↗
InAdicExpansion(AdicNumeral(10,13),8)\mathrm{AdicExpansion}(\mathrm{AdicNumeral}(10, \frac{1}{3}), 8)Out…66666667\text{…66666667}

the same 1/31/3, 2-adically

live ↗
InAdicExpansion(AdicNumeral(2,13),8)\mathrm{AdicExpansion}(\mathrm{AdicNumeral}(2, \frac{1}{3}), 8)Out…10101011\text{…10101011}

as a list, least significant first

live ↗
InAdicDigits(AdicNumeral(10,13),6)\mathrm{AdicDigits}(\mathrm{AdicNumeral}(10, \frac{1}{3}), 6)Out[7,6,6,6,6,6]\bigl\lbrack7, 6, 6, 6, 6, 6\bigr\rbrack
Scope #

7/25=2⋅5−2+1⋅5−17/25 = 2·5^{-2} + 1·5^{-1}

live ↗
InAdicExpansion(AdicNumeral(5,725),8)\mathrm{AdicExpansion}(\mathrm{AdicNumeral}(5, \frac{7}{25}), 8)Out0.12\text{0.12}

A plain non-negative integer terminates with no infinite tail

live ↗
InAdicExpansion(AdicNumeral(10,42))\mathrm{AdicExpansion}(\mathrm{AdicNumeral}(10, 42))Out42\text{42}

−1-1 is the all-9s repeating tail, since −1=…999-1=\dots999 in Z10\mathbf{Z}_{10}

live ↗
InAdicExpansion(AdicNumeral(10,−1),6)\mathrm{AdicExpansion}(\mathrm{AdicNumeral}(10, -1), 6)Out…999999\text{…999999}

Digits at or above 10 print bracketed, as in [15][15] for hexadecimal −1-1's repeating digit

live ↗
InAdicExpansion(AdicNumeral(16,−1),3)\mathrm{AdicExpansion}(\mathrm{AdicNumeral}(16, -1), 3)Out…[15][15][15]\text{…[15][15][15]}

Digits run least-significant first: −1-1's first four 10-adic digits are all 9

live ↗
InAdicDigits(AdicNumeral(10,−1),4)\mathrm{AdicDigits}(\mathrm{AdicNumeral}(10, -1), 4)Out[9,9,9,9]\bigl\lbrack9, 9, 9, 9\bigr\rbrack
About
Examples8
Checked againstSageMath 2 errorRust 2 error

See also: AdicNumeral, IntegerDigits