Friday, August 9, 2013

== Learning Hexadecimal ==

   Previously we learned to count in binary which is a base 2 system and is used in computers. There are other base systems that the binary system is usually paired with in computers and that is the base 16 system. In hexadecimal there are 16 different digits usable that being 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. the values are 0 to 15 and like in binary and decimal once you go past that you increment and restart the sequence.

Take a look at this:

Decimal Hexadecimal
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 A
11 B
12 C
13 D
14 E
15 F

    Lets take the same number as last lesson on binary 3,791 as an example. In hexadecimal that value is ECF. To get a better understanding why the value is what it is, lets convert it to binary. Each digit in hexadecimal can be represented with 4 bits like so:

Binary Hexadecimal
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F

So in turn the number ECF in binary is:

E C F
1110 1100 1111

As you can see it is identical to the previous lesson, the result being 111011001111. You can also use the place value method as well similar to the binary and decimal system but again the place values are different. You again start with 1 and  each number afterward is a power of 16.

256 16 1
E C F
So using the place value method we do (Ex256) + (Cx16) + (Fx1). You can convert the letters to their respective values if that helps like so : (14x256) + (12x16) + (15x1) = 3,791.

More information can be obtained here : http://en.wikipedia.org/wiki/Hexadecimal

No comments: