Hexadecimal

Because binary numbers are difficult to read, a simpler way to represent the same values is sought. Translating from binary to base 10 involves a fair bit of manipulation of numbers; but it turns out that translating from base 2 to base 16 is very simple, because there is a very good shortcut.

To understand this, you must first understand base 16, which is known as hexadecimal. In base 16 there are sixteen numerals: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. The last six are arbitrary; the letters A–F were chosen because they are easy to represent on a keyboard. The columns in hexadecimal are

4 3 2 1
163 162 161 160
4096 256 16 1

To translate from hexadecimal to decimal, you can multiply. Thus, the number F8C represents:


Translating the number FC to binary is best done by translating first to base 10, and then to binary:


Converting 25210 to binary requires the chart:

Col: 9 8 7 6 5 4 3 2 1
Power: 28 27 26 25 24 23 22 21 20
Value: 256 128 64 32 16 8 4 2 1

There are no 256s.

1 128 leaves 124

1 64 leaves 60

1 32 leaves 28

1 16 leaves 12

1 8 leaves 4

1 4 leaves 0

0

0

1 1 1 1 1 1 0 0

Thus, the answer in binary is 1111 1100.

Now, it turns out that if you treat this binary number as two sets of 4 digits, you can do a magical transformation.

The right set is 1100. In decimal that is 12, or in hexadecimal it is C.

The left set is 1111, which in base 10 is 15, or in hexadecimal is F.

Thus, you have:

1111 1100

F C

Putting the two hexadecimal numbers together is FC, which is the real value of 1111 1100. This shortcut always works. You can take any binary number of any length, and reduce it to sets of 4, translate each set of four to hexadecimal, and put the hexadecimal numbers together to get the result in hexadecimal. Here's a much larger number:

1011 0001 1101 0111

The columns are 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, and 32768.

1 * 1 = 1
1 * 2 = 2
1 * 4 = 4
0 * 8 = 0
  
1 * 16 = 16
0 * 32 = 0
1 * 64 = 64
1 * 128 = 128
  
1 * 256 = 256
0 * 512 = 0
0 * 1024 = 0
0 * 2048 = 0
  
1 * 4096 = 4,096
1 * 8192 = 8,192
0 * 16384 = 0
1 * 32768 = 32,768
Total 45,527

Converting this to hexadecimal requires a chart with the hexadecimal values.

65535 4096 256 16 1

There are no 65,536s in 45,527 so the first column is 4,096. There are 11 4096s (45,056), with a remainder of 471. There is one 256 in 471 with a remainder of 215. There are 13 16s (208) in 215 with a remainder of 7. Thus, the hexadecimal number is B1D7.

Checking the math:

B (11) * 4096= 45,056
1 * 256= 256
D (13) * 16 = 208
7 * 1 = 7
Total 45,527

The shortcut version would be to take the original binary number, 1011000111010111, and break it into groups of 4: 1011 0001 1101 0111. Each of the four then is evaluated as a hexadecimal number:

1011 =  
1 * 1 = 1
1 * 2 = 2
0 * 4 = 0
1 * 8 = 8
Total 11
Hex: B
  
0001 =  
1 * 1 = 1
0 * 2 = 0
0 * 4 = 0
0 * 8 = 0
Total 1
Hex: 1
  
1101 =  
1 * 1 = 1
0 * 2 = 0
1 * 4 = 4
1 * 8 = 8
Total 13
Hex: D
  
0111 =  
1 * 1 = 1
1 * 2 = 2
1 * 4 = 4
0 * 8 = 0
Total 7
Hex: 7
  
Total Hex:B1D7

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.101.178