Skip to content

BalancedNumerals ​

Balanced base bb (odd): digits run −(b−1)/2,…,(b−1)/2-(b-1)/2,\dots,(b-1)/2 — it spells negative integers with no sign at all, and rounding to nearest is just truncation. Balanced ternary (b=3b=3) is the famous case.

BalancedNumerals(b)the system, digits −(b−1)/2,…,(b−1)/2-(b-1)/2,\dots,(b-1)/2
Typed signatures
TypePackageApplies
(integer) -> valuenumeralsalways

Domain: Numeral systems

Examples

Basic #

No sign needed: −5=−9+3+1-5 = -9 + 3 + 1

live ↗
InIntegerDigits(−5,BalancedNumerals(3))\mathrm{IntegerDigits}(-5, \mathrm{BalancedNumerals}(3))Out[−1,1,1]\bigl\lbrack-1, 1, 1\bigr\rbrack

100=81+27−9+1100 = 81 + 27 - 9 + 1

live ↗
InIntegerDigits(100,BalancedNumerals(3))\mathrm{IntegerDigits}(100, \mathrm{BalancedNumerals}(3))Out[1,1,−1,0,1]\bigl\lbrack1, 1, -1, 0, 1\bigr\rbrack
About
Examples2

See also: IntegerDigits, NegativeNumerals, BalancedRadix