Skip to content

@enumeratio/numerals ​

Numeral-system extensions for @cortex-js/compute-engine. compute-engine's IntegerDigits and FromDigits already do fixed radix, so this package adds no head for that case — it widens the base slot to accept a system value, the way Wolfram's IntegerDigits[n, MixedRadix[…]] does: FactorialNumerals, ZeckendorfNumerals, BalancedNumerals(b), NegativeNumerals(b), BijectiveNumerals(k), MixedRadixNumerals([…]), PrimorialNumerals, CombinatorialNumerals(k), ResidueNumerals([…]), AdicNumerals(b, prec?) and PositionalNumerals(b) are all just values passed where an integer base would go. An integer base still goes to the native handler, unchanged. Builds on @enumeratio/residues for the residue system and gcd.

AdicNumeral (singular) is a separate value head: the bb-adic number itself, with its own arithmetic (Add/Multiply/Negate/Divide/Power widened to carry it), infinite to the left rather than the right.

The old one-word-per-flavour names (Factoradic, Zeckendorf, BalancedRadix, Radix, …) still evaluate to their …Numerals spelling — see NUMERAL_ALIASES.

Usage ​

ts
import { declareNumerals } from "@enumeratio/numerals";
import { declareAdic } from "@enumeratio/numerals"; // AdicNumeral alone, without the systems

declareNumerals(ce); // declares AdicNumeral too

./src is exported for workspace packages needing the plain TypeScript.

IntegerDigits(42, AdicNumerals(10, 6))   // the 10-adic digits of 42, width 6
IntegerDigits(-3, BalancedNumerals(3))   // balanced ternary spells the sign in the digits

Heads ​

Numeral systems (values for the base slot)

b-adic values

Digits and strings

See also ​

See Numeral systems for why a numeral system is a bijection between integers and digit strings, and a table of every system this package adds. See b-adic numbers for how AdicNumeral and AdicNumerals relate, and where they part ways off the non-negative integers.

Builds on @enumeratio/residues (residues) for ResidueNumerals and gcd. @enumeratio/number-theory (number-theory) depends on this package.

Pages ​