How to convert between decimal, binary and hexadecimal

For a Cisco exam, you need to be able to very quickly convert between Decimal, Binary, and Hexadecimal and back again.

Being able to recreate the below tables will greatly help will this

Decimal to Binary and Back Again

1286432168421
        

A decimal number for example 172 is represented in binary as 1 byte which I am sure we all know 1 byte is 8 bits (binary digits). So using the above table if I want to work out what 172 is in binary  I simply need to “turn on” the bits from left to right until I make 172.

Example 1: What is 172 in binary?

1286432168421
 1 0 1 01 10 0

128 + 32 + 8 + 4 = 172

Example 2: What is 255 in binary?

1286432168421
 1 1 1 11 11 1

128 + 64 +32 +16 + 8 +4 +2 +1 = 255

Example 3: What is 192 in binary?

1286432168421
 1 1 0 00 00 0

128 + 64 = 192

Decimal to Hexadecimal and Back Again

The easiest way to convert between decimal and hexadecimal if to go to IP first, and being able to reproduce the below table during the exam helps, so start learning how to count to 15 in binary!

DecimalBinaryHexidecimal
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
101010A
111011B
121100C
131101D
141110E
151111F

As you can see a hexadecimal number represents 4 bits, lets go so converting

Example1: Decimal 176 to Hexadecimal

1) The first thing we need to do is convert 176 to binary using the same method we used before

176 = 10110000

2) A hexadecimal digit can only only be 4 bits so the next step is to break our binary result in two

1011 0000

3) Now we simply use the above table

1011 = B

0000 = 0

4) The answer is

176 = 1011000 = 0xB0

The 0x just lefts everyone know this a hexadecimal number.

Example 2: Decimal 224 to Hexadecimal

1) 224 = 1110000 (128 + 64 +32)

2) 1110 0000

3) 1110 = E        0000 = 0

4) 224 = 11100000 = 0xE0

Example 3: 0xF7 to Decimal

 

This time we just do things in reverse

1) F = 1111         7 = 0111

2) 11110111 = 247 (128 + 64 +32 +16 + 4 + 2 + 1 or 255 – 8)

3) The answer is 0xF7 = 11110111 = 247

Practice Makes Perfect!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.