]>
Book Contents Previous Section 9.64 Quaternion Next Section 9.66 RealClosure Book Index

## 9.65 RadixExpansion

It possible to expand numbers in general bases.

Here we expand 111 in base 5. This means

111::RadixExpansion(5)

421

Type: RadixExpansion 5

You can expand fractions to form repeating expansions.

(5/24)::RadixExpansion(2)

0.001 10‾

Type: RadixExpansion 2
(5/24)::RadixExpansion(3)

0.0 12‾

Type: RadixExpansion 3
(5/24)::RadixExpansion(8)

0.1 52‾

Type: RadixExpansion 8
(5/24)::RadixExpansion(10)

0.208 3‾

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.3 5‾

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.3 7307‾

Type: RadixExpansion 8

The operation wholeRagits wholeRagits RadixExpansion 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 prefixRagits RadixExpansion and cycleRagits cycleRagits RadixExpansion 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 Axiom know the base of the ragits.

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

554.3 7307‾

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.123 B 0‾

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 RadixExpansion.

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

More examples of expansions are available in DecimalExpansionXmpPage , BinaryExpansionXmpPage , and HexadecimalExpansionXmpPage .

Book Contents Previous Section 9.64 Quaternion Next Section 9.66 RealClosure Book Index