- Introduction
- Binary
- Hexadecimal
- Conversion Between Binary, Hex, and Decimal
- IP Address Components
- Subnetting
- Exam Prep Questions
- Answers to Exam Prep Questions
Conversion Between Binary, Hex, and Decimal
The following sections provide an introduction to converting between binary, hex, and decimal. Again, there is more than one mathematical approach to finding the correct answer, but the method shown is simple and reliable.
Decimal to Hexadecimal Conversions
The easiest way to get from decimal to hexadecimal and back is to go through binary. Take the example we used earlier in which we converted 176 decimal to binary:
176 = 10110000
Given that a single hex character represents 4 binary bits, all we need to do is to break the 8-bit string 10110000 into two 4-bit strings like this:
1011 0000
Now, simply match the 4-bit strings to their hex equivalent:
1011 = B
0000 = 0
The answer is simply 10110000 = 0xB0.
The "0x" in front of the answer is an expression that means "the following is in hex." This is needed because if the hex value was 27, we could not distinguish it from 27 decimal.
Hexadecimal to Decimal Conversions
The reverse of the procedure is easier than it seems, too. Given a hex value of 0xC4, all we need to do is to first convert to binary, and then to decimal.
To convert to binary, take the two hex characters and find their binary value:
C = 1100
0100 = 4
Now, make the two 4-bit strings into one 8bit string:
11000100
Finally, add the bit values of the columns where you have a 1:
128 + 64 + 4 = 196