Before you are introduced to binary numbering, let's begin by taking you back to your early childhood when you learnt to count using decimal numbering.
You would have learnt that there are ten decimal values:
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
When you get to nine, you have exhausted the available values and you have to:
- Add a column to the left and set it to one.
- Return the unit column on the right to zero.
You then have the values:
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
By repeating this process with the ten's column you then have:
- 20, 30, 40. 50, 60, 70, 80, 90
When you reach 99 you then:
- Add another column to the left.
- Reset the units and tens back to zero.
- Then continue the process as before.
You then have the values:
- 100, 101, 102...
Introduction to binary
A binary numbering scheme only has two possible values, 1 or 0. You may have heard the term ‘on’ or ‘off’, which can be represented by:
- 1 = on
- 0 = off
The word binary comes from ‘Bi’ meaning two. Words like bicycle (two wheels) and binoculars (a pair of telescopes mounted side by side) are common examples.
Due to the nature of the way computers are designed and work, they can only deal with two values. You will have heard the term ‘bits’, for example, a 32-bit or 64-bit processor. The word ‘bit’ is short for Binary digit.
These two states of ‘on’ or ‘off’ are used in computer storage, processing and communications or networking. Programmers often call their executable files ‘binaries’ when they have a file extension of ‘.bin’.
Conversion of binary to decimal
Binary numbers can look odd when they are written in full, as they tend to be long numbers. This is due to the digit value increasing by the power of two, rather than by powers of ten:
- 1, 10, 100, 1000 etc.
With binary, we see the column increase by the power of two:
- 1, 2, 4, 8, 16, 32 etc.
Each column effectively doubles the previous value to the right.
The decimal equivalent of its binary value can be found by summing all the binary digits that are set to one as shown in the example below:
Decimal |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
Binary |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
Therefore, the binary value of 1 0 1 0 1 0 1 is equal to the decimal value: 85
The calculation is 64+16+4+1 = 85
Note that 32, 8 and 2 are set to zero (off).
If 2 was set to one what would be the new decimal value?
IPv4 address
The most common address you will encounter as a network engineer is an IPv4 address.
This IPv4 address, with a total of 32 bits, is broken down into four equal-sized segments, then represented as decimal. This is known as ‘Dotted Decimal Notation’.
Example: 192.168.1.254
If the above value was written in binary it would look like this:
- 11000000101010000000000111111110
Imagine trying to tell a colleague this binary address during a telephone conversation. The likelihood of an error would be high.
You have learnt that Dotted Decimal Notation breaks the binary values down into eight-bit segments, converts them into decimal, each separated with a dot. So if you split the binary value into eight-bit segments you get:
Binary |
1100 0000 |
1010 1000 |
0000 0001 |
1111 1110 |
Then convert each segment to decimal:
Decimal |
192 |
168 |
1 |
254 |
Binary |
1100 0000 |
1010 1000 |
0000 0001 |
1111 1110 |
Example calculation for the first segment:
Decimal |
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
Binary |
1 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
128 + 64 = 192
And so on for each segment until you get: 192.168.1.254.
Using this approach the maximum value of each of the four decimal values is 255.
This would be 1111 1111 in binary.
Think of where you have seen an IPv4 address that looks like this:
- 255.255.255.0
It's a class C subnet mask that has the most significant 24 bits set to 1:
- 11111111 11111111 11111111 00000000
As a Network Engineer, familiarity with binary to decimal conversion, and vice versa will help you immensely.
Answer to question
The new decimal value is 87.
Did you get it right?
When you're ready, please mark this task as complete by clicking the blue icon in the top right-hand corner.
As children we learned to count using decimal, and that there are 10 decimal values: The easiest way to carry on counting after 9, is putting a one, on the left-hand side of each number. 0 becomes 10, 1 becomes 11 and so on. You then have the values: 10, 11, 12, 13, 14, 15, 16, 17, 18 and 19. By repeating this process with the ten's column, you then have: 20, 30, 40, 50, 60, 70, 80 and of course 90. All of the numbers we can possibly think of, use a combination of those digits. A binary numbering scheme, however, only has two possible values: one or zero. Where one is referred to as ‘on’, while zero is ‘off’.
The word binary comes from ‘Bi’ meaning two. Words like bicycle (two wheels) and binoculars (a pair of telescopes mounted side by side) are common examples. In the digital realm, computers are designed to use binary language to function. So, in order to program, you’ll need to understand how binary works. So let’s give this topic a closer look.
You’re likely to have heard the term ‘bits’ before. For example: a 32-bit or 64-bit processor. The word ‘bit’ is short for Binary digit, meaning it’s just a single number: a one or a zero. These bits can be combined to create larger files, like bytes or megabytes… that we use to measure the size of our files. You will never convert such large files into decimal numbers; nevertheless, understanding how smaller binary numbers correspond to decimal numbers may prove to be very handy in your everyday activities. For this reason, let’s see how binary numbers correspond to decimal numbers using a table.
Binary numbers can look odd and quite confusing, when they are written in full. This is because the digit value is increasing by the power of two, rather than what we’re used to: in decimal numbers, they increase by powers of ten. This means that they use: 1, 2, 4, 8, 16, 32 etc. Instead of 1, 10, 100, 1000 etc. To calculate the binary value: add up all the numbers that are ‘on’ in the table. For example, the binary value of 1 0 1 0 1 0 1 is calculated as 64+16+4+1, which equals 85. Note that 32, 8 and 2 are set to zero or off, so we don’t include them in the calculation.
Now let’s look at a more practical use of the binary code. For that, let’s take an IP address. The most common address you will encounter as a network engineer is an IPv4 address. An IPv4 address is 32 bits long. As I mentioned earlier, each binary digit is a bit. Hence, this IPv4 address is made up of 32 binary digits. This IPv4 address, with a total of 32 bits, is broken down into four equal-sized segments, then represented as decimal. This is known as ‘Dotted Decimal Notation’. For example: during a telephone conversation, we tend to repeat a phone number a couple times to double check it’s the right number. Imagine trying to tell a colleague this binary address during a telephone conversation. Chances are, you’d make a mistake.
When we type in an IP address, the computer converts it into binary automatically. To fully understand how IP addresses work, we need to be able to do the same. So, in a table, if you split the binary value into eight-bit segments you get: 1100 0000 – 1010 1000 – 0000 0001 – 1111 1110. After you’ve done that, convert each segment to decimal.
Now, let’s do the calculation. 128 + 64 = 192 and so on, with each segment until you get: 192.168.1.254. Using this approach, the maximum value of each of the four decimal values is 255. For example, in a class C subnet mask (which has the most significant 24 bits set to 1) the binary would look like this… In summary, Binary to decimal conversion (and vice versa) may seem difficult at first... but once you get the gist of it, you will be able to calculate these in no time... And as a Network Engineer, this will help you immensely!
A world-leading tech and digital skills organization, we help many of the world’s leading companies to build their tech and digital capabilities via our range of world-class training courses, reskilling bootcamps, work-based learning programs, and apprenticeships. We also create bespoke solutions, blending elements to meet specific client needs.