Number Systems | O Level Computer Science 2210 & IGCSE Computer Science 0478 | Detailed Free Notes To Score An A Star (A*)
1.0 Lesson Objectives
1.1 Basics of Computer
In computer, 1 means on and 0 means off
- Everything must be converted to this machine language
- the computer understands only machine language
- The denary number system is where the base is 10.
- For example, saying 1000 in denary system is 10 raised to the power of 3.
- In computers
- Binary number system
- Base is 2.
- Everything explained in terms of 2
2¹ = 2
2² = 4
2³ = 8
Basically
- Every number can be expressed in a binary number
- By putting a 1 for the 2 base that is required to make it and putting a zero to the 2 base that is not required to make it.
For example
| 128 | 64 | 32 | 16 | 8 | 4 | 2 |
So how to convert a number to a binary number.
Say you need to convert 87 to the binary form.
First select the highest 2 base number that is just smaller than it and put a 1 there.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | |
| 1 |
The largest 2 base number which is smaller than 87 is 64 so put a 1 below 64. Now we need 87-64 = 23 more. Which means that the largest 2 base number that is below 23 is 16. So we put a one at 16
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | |
| 1 | 1 |
Now we need 23-16 = 7. Again the largest number below 7 is 4 so we put 1 at 4
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | |
| 1 | 1 | 1 |
Now we need 3 so it would be 2 and 1
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | |
| 1 | 1 | 1 | 1 |
Now put 0 in all other numbers.
- HINT: It does not matter if there is a zero or not on the left side of the largest number used. So here for example, if we do not put zero in 128, it does not matter. Any zeros to the left of the largest number used don’t matter as they don’t change the value, Any zero on the right matters, at the same time any 1 any where changes the value so watch out.
- Most students forget that first base number of 2 is 1 as 2 to the power of 0 is 1, and thus start the number line with 2 which changes everything.
- Don’t forget any zeros on the right, as value would change.
- Number line can go on to any power of 2, it is not necessary to stop at 128. Usually we stop here because these numbers add up to 255, which is the complete code of a byte.
So now
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | |
| 1 | 0 | 1 | 0 | 0 | 1 | 1 |
87 is binary form is 1010011. This is how you convert a denary number to binary number. If you have to convert a number from binary to denary, the same process will be used in reverse.
For example convert 10001110 to denary.
So this would be
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | |
| 1 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
So just add the numbers where there is 1
128 + 8 + 4 + 2 = 142.
So the number 10001110 (binary) in denary form in 142.
Hexadecimal
A binary digit is equal to one BIT (up to 255 maximum).
- A collection of 8 bits together is a byte which is the smallest unit of computer memory.
- In a 16-bit system, 1 byte is equal to 16 bits rather than 8.
- Any system always have bits in bytes which are multiples of 8.
- Thus 1 Kilobyte is basically 210 bytes, while one megabyte is 220 bytes and so on.
- It has been simplified to 1 Kb = 1000 bytes, 1 MB = 1000 KB etc.
However when measuring RAM, kibibytes, mebibytes etc are used where the old binary method is used. Here in this course the term kilobyte and kibibyte shall be the same with the binary system being used for both.
Binary numbers can be used to describe the functionality of software etc. For example if a 1 for 25 means lights on and 0 means lights off, while a 1 for for 21 means fans on and 0 means off, then 100010 means lights and fans on while 100000 means lights on but fans off which is both binary number format here.
The other common system that is followed is the hexadecimal system, where the base is 16. 1 hexadecimal value has 4 binary values. So basically the 16 digits are
| Hexadecimal Numberer | Denary Value | Binary Code |
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 3 | 3 | 0011 |
| 4 | 4 | 0100 |
| 5 | 5 | 0101 |
| 6 | 6 | 0110 |
| 7 | 7 | 0111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
How to convert a binary number into hexadecimal
- First divide the binary number into block of 4 STARTING FROM THE RIGHT
- For example if the number is 1100011110
- Then the blocks will be, 1110, 0001, 0011
- Remember, blocks are selected from right not values. Secondly, if the last block is short of numbers, as here we had only 11, then add zeros to complete the 4 on the right (Zeros on right dont change values).
- Now convert each block in hexadecimal
- 1110 become E
- 0001 becomes 1
- 0011 becomes 3
- Put back together
- The hexadecimal value becomes 31E
How to convert from hexadecimal to binary.
- Take each number separately. For example for a hexadecimal number F6B
- The 3 numbers would be F, 6, B
- Convert each in binary
- F is 15 which is 1111
- 6 is 0110
- B is 11 which is 1011
- Now put back
- 111101101011
Uses of Hexadecimal
Hexadecimals are used in a number of ways.
- While developing new software, the output of memory values on printer is called memory dump and is done in hexadecimal because it is more easier to read than binary. Thus finding faults is easier. Knowledge of computer architecture is required to do this.
- In HTML, hexadecimal values are used for color coding. It allows for many combinations to be made by assigning 2 hexadecimal values for each of the basic colors, red, blue and green.
- MAC (Media Access Control) or the unique number of every device on the internet is a 48 bits or 64 bits. To make it easier to understand, these 48 values are in 6 groups of hexadecimal digits. How? With 1 hexadecimal representing 4 bits or binary values 6 groups of 2 hexadecimals means 12 hexadecimal values which means 12 x 4 = 48 values. So they are easier to read. Every MAC address is unique and identifies many things, such as who is the manufacturer and so on. They are like NN:NN:NN:DD:DD:DD or NN-NN-NN-DD-DD-DD where the Ns identify the manufacturer and the Ds identify the device
- MAC addresses are either Universally Administrated MAC Addresses (UAA) or Locally Administrated MAC Addresses (LAA)
- UAA is more common where the manufacturer sets it.
- If user wants to change MAC address then LAA is done
- It must be unique or 2 devices will become the same MAC address
- Software Requirements might be the reason for MAC address change required by a user.
- MAC addresses might need to be changed to get past network restrictions in some cases.
- Keyboard values are in ASCII codes where hexadecimal values are usually used for these codes. ASCII stands for American Standard Code For Information Interchange
- Hexadecimal values might be used for web pages. It saves you from fake website address as hexadecimal addresses are unique
- The binary computer memory is called the machine code. Assembly code is less complex than machine code because hexadecimal values can be used thus making it easier for programmers. Remember, this assembly code has to be converted in machine code because the computer only understands machine code in binary format.
