====================================================================
RadixExpansion examples
====================================================================

It possible to expand numbers in general bases.

Here we expand 111 in base 5. This means
  10^2+10^1+10^0 = 4 * 5^2+2 * 5^1 + 5^0

  111::RadixExpansion(5)
    421
                              Type: RadixExpansion 5

You can expand fractions to form repeating expansions.

  (5/24)::RadixExpansion(2)
         __
    0.00110
                              Type: RadixExpansion 2

  (5/24)::RadixExpansion(3)
       __
    0.012
                              Type: RadixExpansion 3

  (5/24)::RadixExpansion(8)
       __
    0.152
                              Type: RadixExpansion 8

  (5/24)::RadixExpansion(10)
         _
    0.2083
                              Type: RadixExpansion 10

For bases from 11 to 36 the letters A through Z are used.

  (5/24)::RadixExpansion(12)
    0.26
                              Type: RadixExpansion 12

  (5/24)::RadixExpansion(16)
       _
    0.35
                              Type: RadixExpansion 16

  (5/24)::RadixExpansion(36)
    0.7I
                              Type: RadixExpansion 36

For bases greater than 36, the ragits are separated by blanks.

  (5/24)::RadixExpansion(38)
                _____
    0 . 7 34 31 25 12
                              Type: RadixExpansion 38

The RadixExpansion type provides operations to obtain the individual
ragits.  Here is a rational number in base 8.

  a := (76543/210)::RadixExpansion(8)
          ____
     554.37307
                              Type: RadixExpansion 8

The operation wholeRagits returns a list of the ragits for the
integral part of the number.

  w := wholeRagits a
    [5,5,4]
                              Type: List Integer

The operations prefixRagits and cycleRagits return lists of the initial
and repeating ragits in the fractional part of the number.

  f0 := prefixRagits a
    [3]
                              Type: List Integer

  f1 := cycleRagits a
    [7,3,0,7]
                              Type: List Integer

You can construct any radix expansion by giving the whole, prefix and
cycle parts.  The declaration is necessary to let FriCAS know the base
of the ragits.

  u:RadixExpansion(8):=wholeRadix(w)+fractRadix(f0,f1)
         ____
    554.37307
                              Type: RadixExpansion 8

If there is no repeating part, then the list [0] should be used.

  v: RadixExpansion(12) := fractRadix([1,2,3,11], [0])
          _
    0.123B0
                              Type: RadixExpansion 12

If you are not interested in the repeating nature of the expansion, an
infinite stream of ragits can be obtained using fractRagits.

  fractRagits(u)
         _______
    [3,7,3,0,7,7]
                              Type: Stream Integer

Of course, it's possible to recover the fraction representation:

  a :: Fraction(Integer)
    76543
    -----
     210
                              Type: Fraction Integer

See Also:
o )help DecimalExpansion
o )help BinaryExpansion
o )help HexadecimalExpansion
o )show RadixExpansion

