Blog of Tips, Tricks & Resources from New Horizons Central

Numbering Systems & Conversions
Nicole Winn

Numbering Systems & Conversions

Converting from one numbering system to another as a basic skill to other skills...

 


 

With anything related to IT someone needs to understand numbering systems and converting from one numbering system to another as a basic skill to other skills. This piece is related to that requirement which is a basic skill in the following CompTIA courses: A+, Network+, Server+, Security+, CASP, Cloud+, and CySA+ as well as Cisco and Microsoft certifications. Anyone with questions is invited to communicate with me at drussell@nhnashville.com and I will be glad to communicate with them. 

 

Conversion from Binary and Hexadecimal to Decimal 

 

In networking, it is sometimes necessary to convert values from Binary to Hexadecimal to Decimal or in reverse. There are three rules for using any numbering system: 

 

Rule 1: The rightmost value is always a value of 1 

Rule 2: The second from the right value is always Base 

Rule 3: All the other values are Base * last 

 

Given these 3 rules, it is possible to convert from any numbering system to any other system fairly easily. For example, if you are converting from Binary (Values of 0 or 1 in each position) to Decimal (Values from 0 through 9 in each position) you create a value range for the number you are converting from as follows: 

 

128 

64 

32 

16 

 

 

These are the value ranges for Binary and each one starts out as a value of zero. If all the values are 1 it would be as so: 

 

128 

64 

32 

16 

 

This represents the range of 1 byte of Binary which is between 0 and 255 (all zeros or all ones). In IP version 4 addressing this would be equivalent to one octet of a 4 octet (32 bit IPV4 address range). So you just have to solve it one byte at a time (or 8 bits) in each octet.

 

An IP address of 192.168.15.4 would be solved as follows by adding the bit values together: 

 

First Octet (on left) a value of 192 (which is 128 + 64) 

 

128 

64 

32 

16 

 

 

The second octet from the left (which would be 168, a value of 128+32+8 )would be solved as follows: 

 

128 

64 

32 

16 

 

 

The third octet from the left (which would be 15, a value of 8+4+2+1) is as follows: 

 

128 

64 

32 

16 

 

 

The final octet on the right (which would be 4 would be as follows: 

 

128 

64 

32 

16 

 

We would have the following in Binary: 11000000.10101000.00001111.00000100 which is the equivalent of 192.168.15.4 in Decimal.  In the above operation we start with the Binary and solve each octet to Decimal. 

 

The reverse of this is to convert the Decimal value to Binary, which would be a similar operation. Let’s say we have the following: 164.49.86.125 in Decimal and need to convert it to Binary. The operation is as follows: 

 

Decimal Value to Binary

 

First we take the left most octet of 164 and look for the largest value that will go into that, so we have 164 and 128 will go into it 1 time so we put a 1 in the 128 position: 

 

128 

64 

32 

16 

 

 

At this point we subtract 128 from 164 and get 36. Will 64 go into 36…no, so we put a 0 in the 64 position. Will 32 go into 36? Yes, so we put a 1 in the 32 position and subtract 32 from 36 and get 4: 

 

128 

64 

32 

16 

 

 

So now we have the following when we fill in a 1 in the 4 position:

 

128 

64 

32 

16 

 

 

That means that the left most octet is 10100100 in binary. The next octet would be 49 would result in the following which is 49- 32-16-1 or 49 for the third octet from the right: 

 

128 

64 

32 

16 

 

The second octet would be for 86 as follows: 86-64-16-4-2 which would be as follows: 

 

128 

64 

32 

16 

 

The final octet on the right would be solved as follows: 125 which would be 125-64-32-16-8-4-1: 

 

128 

64 

32 

16 

 

 

That takes care of Binary and Decimal conversion in either direction. 

 

Next, we will have Binary to Hexadecimal which is Base 16. This is odd in that the numbers that are part of the numbering system include letters as well as numbers. 

 

In Base 2 we had 1 or 0 only, in Base 10 we had 0,1,2,3,4,5,6,7,8 and 9 only.

 

But in Hexadecimal we have 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F with the A being 10, and the B being 11, and the C being 12, and the D being 13, and the E being 14, and the F being 15. Yes, letters are numbers in Base 16 but this is actually easier to convert than Binary to Decimal.

 

The number system is as follows: 

 

0

0

0

0

4096

255

16

1

 

 

So the following in Hex AB64 would actually be as follows: 

 

A

B

6

4

4096

255

16

1

 

 

This would be A (or 10) * 4096 + B (or 11) * 255 + 6 * 16 + 4 *1 or 43876. 

 

Converting Hex to Binary

 

When it comes to converting Hex to Binary it is even easier. The rightmost octets of Hex will convert easily to binary as so where each group of 4 binary values equal one character in Hex. Using the same values as above AB64 in Hex gives us the following in Binary: 

 

A (or 10) is  

 

1

 

 

While B (or 11) is 

 

 

 

6 is  

 

 

 

While 4 is 

 

 

 

Converting Binary to Hex is equally simple: 

 

1101 is 13 

 

 

Of course 1111 is 15 

 

 

 

I hope this has helped in some regard to make it easier to convert in numbering systems and the next thing to take under consideration is how this all figures into Complex Subnetting and Supernetting (CIDR). Thank you, 

Previous Article Social Engineering and Cybercrime – ACE In The Hole
Next Article CLD Corner with Dr. Jason Pugh: Writing with PAT
Print
71

Theme picker

Loader