FromDigits
The integer a digit string denotes, in any numeral system. The inverse of IntegerDigits — and the round trip is the whole specification of a system.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram Language
FromDigits!FromDigits([d1, d2, …])integer formed from a digit list in base 10.FromDigits(string, base?)integer formed from a digit string, 0-9 then a-z.SageMath
sum(d * (base?)^k for k, d in enumerate(reversed(string)))Rustfrom_digits(string, base?)FromDigits([d1, d2, …], base)integer formed from a digit list in the given base.FromDigits(digits, system)read the digits in that systemSageMath
sum(d * (system)^k for k, d in enumerate(reversed(digits)))Rustfrom_digits(digits, system)FromDigits(roman, "Roman")the integer a Roman numeral spells, the inverse of RomanNumeral.SageMath
sum(d * ("Roman")^k for k, d in enumerate(reversed(roman)))Rustfrom_digits(roman, "Roman")FromDigits(digits, x)a symbolic base gives the polynomial the digits spell in x.SageMath
sum(d * (x)^k for k, d in enumerate(reversed(digits)))Rustfrom_digits(digits, x)FromDigits(digits, negativeBase)a negative base reads with the same Horner reduction as a positive one.SageMath
sum(d * (negativeBase)^k for k, d in enumerate(reversed(digits)))Rustfrom_digits(digits, negativeBase)FromDigits({digits, exponent})reads the single {digits, exponent} pair RealDigits itself returns, base 10.SageMath
sum(d * (exponent})^k for k, d in enumerate(reversed({digits)))Rustfrom_digits({digits, exponent})Typed signatures
| Type | Package | Applies |
|---|---|---|
(collection<any>, integer?) -> integer | compute-engine | always |
(collection<any>, any?) -> integer | numeralsreplaces compute-engine | always |
Details
- A digit string that denotes NO integer leaves the call standing: two adjacent Zeckendorf ones, an out-of-range mixed-radix digit, residues that no integer satisfies
- In a residue system with moduli that are not pairwise coprime the map is not a bijection, and an inconsistent string has no value
- Zeckendorf is the clearest case of a system whose digits are constrained by a forbidden PATTERN rather than a per-place bound
- Reading a
ResidueNumeralsnumeral IS the Chinese remainder theorem: the digits are the ResidueClass classes of , and ChineseRemainder of those classes gives it back - In a fixed base, the inverse of IntegerDigits: for .
- Digits need not be restricted to -- a digit base simply carries into higher place values.
- An empty digit list has no natural value; compute-engine leaves it unevaluated rather than returning 0.
- compute-engine's FromDigits takes a list of digits, not a digit string.
Examples
14 more kept as data, checked against the oraclesScope #
Properties #
About
| Examples | 38 |
|---|---|
| Checked against | Wolfram Language 25 agree2 differSageMath 11 agree1 unevaluated7 errormathlib4 10 agree1 unevaluated8 errorRust 4 agree6 error |
| Crosswalk | Wolfram LanguageSageMath ×2Rust |
Implementation
mapped
sagepackages/oracle/src/mappings.tsmapped
sagepackages/oracle/src/mappings.tsmapped
rustpackages/oracle/src/mappings.tsA list of digits and an integer base from 2 to 256.
mapped
mathlib4packages/oracle/src/mappings.tsNat.ofDigits is Horner's rule over a little-endian list, so the list is reversed; digits past the base carry as ours do. Natural digits only, and an empty list is 0 where ours stays unevaluated.
mapped
mathlib4packages/oracle/src/mappings.tsAs the one-argument row, in an integer base read over ℤ so a negative base is the same Horner reduction; a digit string or symbolic base is a type error.
See also: IntegerDigits, NumeralSystemShape, ChineseRemainder