1 1. Computer Systems / Understanding Binary


Number Systems
Number systems are an integral part of Computer Science. Understanding the Denary, Binary and Hexadecimal number systems will allow you to gain a deeper understanding of how computers work.
What is a number system?
A number system is simply a system used for representing numbers.
There are hundreds of different number systems If you wish to explore some of these then follow this link CLICK HERE
There are hundreds of different number systems If you wish to explore some of these then follow this link CLICK HERE
The Denary Number System
Denary, also known as Decimal is the number system that we human beings are most familiar with. It is the standard number system around used around the world.
The Denary number system uses 10 digits which are then used to represent all numbers. These digits are:
O 
1 
2 
3 
4 
5 
6 
7 
8 
9 
As Denary uses 10 digits it is referred to as a BASE 10 number system.
Using the 10 digits available in Denary we can represent every number by applying place values to each digit.
Look at the table below, here we have set up place values and added the digits 3,2,7 and 1 beneath them.
Look at the table below, here we have set up place values and added the digits 3,2,7 and 1 beneath them.
Thousands 
Hundreds 
Tens 
Units 
3 
2 
7 
1 
Adding the digits 3,2,7 and 1 beneath these place values has allowed us to create the number 3271. This is interesting as we have created such a large number using only digits from the 10 that are available in the Denary number system.
How does this work?
To arrive at the number 3271 we simply multiply the denary value by the place value and then add up each of the columns:
How does this work?
To arrive at the number 3271 we simply multiply the denary value by the place value and then add up each of the columns:
Thousands 
Hundreds 
Tens 
Units 
3 
2 
7 
1 
3 X 1000 
2 X 100 
7 X 10 
1 X 1 
= 3000 
= 200 
= 70 
= 1 
3000 + 200 + 70 + 1 = 3271
More Detail!
In the Denary number system the place values are actually derived by 10^X
X in this equation would start at 0 on the right most value (Units) and increase by 1 each time you add a digit to the left.
See the table below for visualization.
X in this equation would start at 0 on the right most value (Units) and increase by 1 each time you add a digit to the left.
See the table below for visualization.
10 Thousands 
Thousands 
Hundreds 
Tens 
Units 
10^4 
10^3 
10^2 
10^1 
10^0 
10000s 
10000s 
100s 
10s 
1s 
Need a larger number?
The Denary system easily scales up to allow for larger numbers, simply add more place values to the left to achieve this.
The Denary system easily scales up to allow for larger numbers, simply add more place values to the left to achieve this.
The Binary Number System
Just like Denary, Binary is also a number system. Binary differs from Denary as rather than using 10 digits to represent numbers it only uses 2.
The two digits used by the Binary number system are:
O 
1 
As Binary uses 2 digits it is referred to as a BASE 2 number system.
Using the 2 digits available in Denary we can represent every number by applying place values to each digit.
Each single binary number (1 or 0) is referred to as a bit. We can combine multiple bits in different patterns by applying place values to each digit. This works in a very similar way to the Denary number system.
The difference in method when working with the Binary number system is that the place values are generated by using 2^X rather than 10^X. We use 2 rather than 10 due to the fact that it is a base 2 number system. So using this equation we can generate the following place values:
Using the 2 digits available in Denary we can represent every number by applying place values to each digit.
Each single binary number (1 or 0) is referred to as a bit. We can combine multiple bits in different patterns by applying place values to each digit. This works in a very similar way to the Denary number system.
The difference in method when working with the Binary number system is that the place values are generated by using 2^X rather than 10^X. We use 2 rather than 10 due to the fact that it is a base 2 number system. So using this equation we can generate the following place values:
2^7 
2^6 
2^5 
2^4 
2^3 
2^2 
2^1 
2^0 
128 
64 
32 
16 
8 
4 
2 
1 
Another way to quickly generate these place values is to start with 1 on the right most bit and double it each time that you add a value to the left. You can continue to double for as many numbers as you need, See below example.
64 X 2 
32 X 2 
16 X 2 
8 X 2 
4 X 2 
2 X 2 
1 X 2 
1 
128 
64 
32 
16 
8 
4 
2 
1 
Once you have your place values set up then you can insert your bits beneath then to represent any number. This process allows us to convert Binary numbers into Denary and vice versa.
Binary and Denary Conversions
To understand binary numbers further, we need to know how to convert them. We need to convert them from Binary to Denary and vice versa.
To begin this process you should can draw out a little table including the Binary place values as explained above. This table will look like this:
128 
64 
32 
16 
8 
4 
2 
1 
Binary to Denary Conversion
We can now use the above table to convert any 8 bit Binary number into a Denary number. For this example I would like to convert the number 11001010 into Denary.
Step 1  Place the values into the table beneath the place values:
We can now use the above table to convert any 8 bit Binary number into a Denary number. For this example I would like to convert the number 11001010 into Denary.
Step 1  Place the values into the table beneath the place values:
128 
64 
32 
16 
8 
4 
2 
1 
1 
1 
O 
O 
1 
O 
1 
O 
Step 2  Add together the place values that have a 1 beneath them. Ignore the place values that have a 0 beneath them.
In this example we would add the following numbers  128 + 64 + 8 + 2
Adding these 4 numbers would give us the answer  202 we can therefore conclude that 11001010 = 202 in Denary
In this example we would add the following numbers  128 + 64 + 8 + 2
Adding these 4 numbers would give us the answer  202 we can therefore conclude that 11001010 = 202 in Denary
Denary to Binary Conversion
If you are given a Denary number e.g. 94 and asked to convert it into binary then you will need to follow these steps:
Step 1  Draw out a table detailing the Binary place values
If you are given a Denary number e.g. 94 and asked to convert it into binary then you will need to follow these steps:
Step 1  Draw out a table detailing the Binary place values
128 
64 
32 
16 
8 
4 
2 
1 
Step 2  Place a 1 under each place value ensuring that when added together they equal your desired Denary number, in this case we which to find the Binary for 94. Place a 0 under each of the place values that you will not need.
128 
64 
32 
16 
8 
4 
2 
1 
O 
1 
O 
1 
1 
1 
1 
O 
In the table above we have determined that 64 + 16 + 8 + 4 + 2 = 94. Due to this fact, we have placed a 1 under each of the corresponding place values. This allows us to conclude that 94 in Binary = 01011110
Binary length
In the binary conversion examples above we have only used 8 bit (8 digit) long examples e.g. 01011110
An 8 bit long Binary number is a very commonly used measurement and it is referred to as a Byte.
1 Byte = 8 bits long.
The largest number that you can make with 8 bits is 255, You can achieve this with 8 1s e.g. 11111111
You can actually make 256 different numbers with 8 bits as you can also represent 0 with 8 0s e.g. 00000000
But what if you want to represent a number larger than 255? Well this is actually simpler than you might think. The solution is to use more bits! Each time you add a new bit place value to the left it will double. You can continue to add place values and doubling them until you can accommodate your desired number.
The largest binary number that you will be asked to deal with by CAIE is 16 bits long. The place value table for this would look like:
An 8 bit long Binary number is a very commonly used measurement and it is referred to as a Byte.
1 Byte = 8 bits long.
The largest number that you can make with 8 bits is 255, You can achieve this with 8 1s e.g. 11111111
You can actually make 256 different numbers with 8 bits as you can also represent 0 with 8 0s e.g. 00000000
But what if you want to represent a number larger than 255? Well this is actually simpler than you might think. The solution is to use more bits! Each time you add a new bit place value to the left it will double. You can continue to add place values and doubling them until you can accommodate your desired number.
The largest binary number that you will be asked to deal with by CAIE is 16 bits long. The place value table for this would look like:
32768 
16384 
8192 
4096 
2048 
1024 
512 
256 
128 
64 
32 
16 
8 
4 
2 
1 
Once you have a table with enough place values ready then you can begin to add your 1s and 0s as necessary to represent your desired number.
Why do computers use Binary?
Computers are built using millions of electronic circuits and transistors.
Transistors are simple switches that can either be switched ON or OFF.
Transistors are simple switches that can either be switched ON or OFF.
This essentially means that at the lowest possible level of a computer, all that it is capable of is turning electricity on and off on different circuits.
The capability of switching electricity on and off provides us with 2 possible states.
The capability of switching electricity on and off provides us with 2 possible states.
State 1 
State 2 
On 
Off 
As there are only two possible states (On and Off), the Base 2 Binary system is a perfect fit.
Each digit in the Binary number system can be assigned to the two possible states of an electronic circuit within a computer i.e. 1 = On and 0 = 0ff:
Each digit in the Binary number system can be assigned to the two possible states of an electronic circuit within a computer i.e. 1 = On and 0 = 0ff:
State 1 
State 2 
On 
Off 
1 
O 