Expansions in other Bases
It is possible to expand numbers in general bases. Here we expand
111 in base 5. This means
2 1 0 2 1 -
10 +10 +10 = 4*5 +2*5 +5
You can expand fractions to form repeating expansions.
For bases from 11 to 36 the letters A through Z are used.
For bases greater than 36, the ragits are separated by blanks.
The RadixExpansion type provides
operations to obtain the individual ragits. Here is a rational number
in base 8.
The operation wholeRagits returns
a list of the ragits for the integral part of the number.
The operations prefixRagits and
cycleRagits returns lists of the
initial and repeating ragist in the fractional part of the number.
You can construct any radix expansion by giving the whole, prefix, and
cycle parts. The declaration is necessary to let Axiom know the base
of the ragits.
If there is no repeating part, then the list [0] should be used.
If you are not interested in the repeating nature of the expansion,
an infinite stream of ragits can be obtained using
fractRagits
Of course, it's possible to recover the fraction representation:n
Issue the system command
to display the full list of operations defined by
RadixExpansion. More examples of
expansions are available in
DecimalExpansion,
BinaryExpansion, and
HexadecimalExpansion