Converting between bases
Now that we have the basic knowledge about base-n numbers, let's move on and see how these numbers transform between different bases. We can transform numbers in any base to base-10 and vice versa. In this section, we will show the conversion between different bases along with examples and Python code.
Converting base-n numbers to decimal numbers
Using the definition of base-n numbers given previously, we can convert the following numbers to base-10, or decimal, form. Several examples follow:
- (a)n = a ∙ n0 = a
- (ab)n = a ∙ n1 + b ∙ n0 = an + b
- (abc)n = a ∙ n2 + b ∙ n1 + c ∙ n0 = an2 + bn + c
- (abcd)n = a ∙ n3 + b ∙ n2 + c ∙ n1 + d ∙ n0 = an3 + bn2 + cn + d
We can apply this according to the number of digits we have.
Example – Decimal value of a base-6 number
Let's convert the number (3214)6 into decimal form for this example:
(3214...