Mixed-Radix Computations
MixedRadix allows working with numerical systems in which different digits of a number correspond to different bases.
These are names of several units of soldiers in a Roman army.
In[1]:=
units = {"legion", "cohort", "century", "contubernia", "soldier"};
A legion was made of 10 cohorts, a cohort of 6 centuries, a century of 10 contuberniae, and a contubernia of 8 soldiers.
In[2]:=
bases = MixedRadix[{10, 6, 10, 8}];
Number of soldiers in a contubernia, using this number system.
In[3]:=
FromDigits[{1, 0}, bases]
Out[3]=
Number of soldiers in a century.
In[4]:=
FromDigits[{1, 0, 0}, bases]
Out[4]=
Number of soldiers in a cohort.
In[5]:=
FromDigits[{1, 0, 0, 0}, bases]
Out[5]=
Number of soldiers in a legion.
In[6]:=
FromDigits[{1, 0, 0, 0, 0}, bases]
Out[6]=
Vice versa, decompose the number of soldiers in these tactical units.
In[7]:=
IntegerDigits[16894, bases]
Out[7]=
In[8]:=
IntegerDigits[16894, bases];
Thread[units -> %]
Out[8]=