All you Ever Wanted to Know About Multi-Base Numbers
1. Intro
A lot of people ask me about multi-base numbers... If you're a long-time reader of emblazon, you'll know by now: these things don't get explained all at once. These things don't get understood in a night-time. These Math things: they are best enjoyed with patience and a sip of relaxation.
2. Original Usage
The original use of MultiBase numbers, way back in 2009, was to assign identifiers to kernel tasks in a toy operating system used as someone's Master's thesis.
3. Introduction to the Theory of Multi-Base Numbers
In a nutshell, a MultiBase number is a string of characters where each character may have its own base...
Mike Meyers, not in a nutshell
3.1 Simple Multi-Base Numbers
Axioms:
Assume n is the base of a given character
Then:
A Simple MultiBase Number has each character's value ranging from 0 to n - 1
Each character would be interpreted in isolation
The order of characters is not important
It is an un-ordered collection of single characters of disparate bases
It is a Set
A Simple MultiBase Number is also known as a Context-Free MultiBase Number
3.2 Complex Multi-Base Numbers
Axioms:
Assume n is the base of a given character
Then:
A Complex MultiBase Number has each character ranging from 0 to (potentially) ∞
Each character's true value is determined by its distance from the decimal -- if it is located at index 0, it is the raw value... if it is located at index 1, it is the raw value plus n, etc
The order of characters is important
It is an ordered collection of single characters of disparate bases
It is a List
A Complex MultiBase Number is also known as a Context-Dependent MultiBase Number
3.3 Compound Multi-Base Numbers
Axioms:
You've read the previous sections
Assume n is the base of a given character
Then:
A Compound MultiBase Number may be either Simple or Complex
Each item in the set may be, itself, a String of characters
Whereas in a (Basic) MultiBase Number: each item is a single character whose display can range from 0 to n - 1
In a Compound MultiBase Number: each item is a String of characters whose display can range from 0 to (potentially) ∞
3.4 A Basic Example of a Mutli-Base Number
In a Uniform Base Number, "2A" would be interpreted in either base 3 or base 16. Since the characters of base 3 are just 0, 1, and 2, this cannot be a base 3 number. Let's look at it like it's a base 16 number and see what it looks like: 2A =
((1 * 16) + 2) + ((0 * 16) + 11) =
(16 + 2) + (0 + 11) =
(18) + (11) =
18 + 11 =
39
But that's not what 2A is in MultiBase... In our example above, 2A is in base 3.16...
4. Doing the Math on Compound Multi-Base Numbers
Let's take the MultiBase Number 21-A8 in base 3.16 and compute it's Uniform Decimal Value:
4.1 Calculating The Uniform Decimal Value of 21-A8 as a Simple Multi-Base Number in Base 3.16
Index 0: A8 in base 16 =
((1 * 16) + 11) + ((0 * 16) + 8) =
(16 + 11) + (0 + 8) =
(27) + (8) =
27 + 8 =
35
Index 1: 21 in base 3 =
((1 * 3) + 2) + ((0 * 3) + 1) =
(3 + 2) + (0 + 1) =
(5) + (1) =
5 + 1 =
6
So the Uniform Decimal Value of [21-A8/3.16 (simple)] is [6-35 (uniform-decimal)]
4.2 Calculating The Uniform Decimal Value of 21-A8 as a Complex Multi-Base Number in Base 3.16
Index 0: A8 in base 16 = 35 Index 1: 21 in base 3 beginning at True Index 2 =
((3 * 3) + 2) + ((2 * 3) + 1) =
(9 + 2) + (6 + 1) =
(11) + (7) =
11 + 7 =
18
So the Uniform Decimal Value of [21-A8/3.16 (complex)] is [18-35 (uniform-decimal)]
5. Conclusion
The uses of MultiBase numbers are myriad. They are an efficient way to store complex information about something. When working with kernels, efficiency is paramount.