Sunday, September 18, 2016

Learning any base numbering system

In previous tutorials I made, I showed how to work with binary (a base 2 system) and hexadecimal (a base 16 system). There are many things they share and principals in their systems which are true. Knowing these principals you can derive and learn any base system quickly and intuitively.

The first thing you must realize is the BASE of the system. This is the determining factor in knowing the place value for each digit. For example if we use the decimal system what we count with everyday we see that it is base 10. That means there are 10 distinguishing characters used in this system. These characters correlate to the digits and in actuality can be any character but for this example we will use the characters we are all familiar with which would be [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]. As you can see there are 10 distinguishing characters or digits.

Lets talk about place values now. Given any base system each place value to the next is calculated by (BASE ^ PLACE).

So in the base 10 system its like this:
...... 10000(or 10^4), 1000(or 10^3), 100(or 10^2), 10(or 10^1), 1(or 10^0).

so given the decimal(base 10) number 54,321 we can see that there are:
5x10000 or 5x(10^4) = 50000
4x1000 or 4x(10^3) = 4000
3x100 or 3x(10^2) = 300
2x10 or 3x(10^1) = 20
1x1 or 1x(10^0) = 1

if you add these all up (50000 + 4000+ 300 + 20 +1) you get 54,321.

Now lets try duodecimal(base 12).
Lets establish the characters [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B].
(where A can be thought of as 10 and B as 11)
now establish the place values.
.......20736(or 12^4), 1728(or 12^3), 144(or 10^2), 12(or 12^1), 1(or 12^0).
so given A53B7:
Ax20769 or Ax(12^4) = A0000
5x1728 or 5x(12^3) = 5000
3x144 or 3x(12^2) = 300
Bx12 or Bx(12^1) = B0
7x1 or 7x(12^0) = 7

if you add these up you get A53B7.

because every system is base based (lol didn't realize this pun until I wrote it) we can just divide the the bases to go from one base to another. using the remainder as the desired next digit in the resulting base's number.
One way is to do long division with the 2 different bases and help with base 10.
I'll get more into converting from any base to any other base in my next post.