The Number System CS
The Number System CS
The Number System CS
Contact:0714980988
The Number System
Number systems are the techniques to represent numbers in the computer system.
A set of values used to represent different quantities is known as Number System.
The digital computer represents all kinds of data and information in binary numbers.
It includes audio, graphics, video, text and numbers.
The number of digits used in a number system is called its base or radix.
The base is written after the number as subscript such as (10101)2 ,(28)10
Since computers contain millions and millions of tiny ‘switches’, which must be in
the ON or OFF position, they can be represented by the binary system.
A switch in the ON position is represented by 1; a switch in the OFF position is
represented by 0.
Types of
Number System
Binary Numbers
(base 2)
Denary/Decimal Hexadecimal
Octal Numbers
numbers Numbers
(Base 8)
(base 10) (Base 16)
Binary Number System
Binary number system uses only two digits that are 0 and 1.
All the computers and electronic devices are using it for their internal processing.
The base of binary number system is 2, as it has only two digits.
Binary numbers are also called the base 2 number system. It can be written as (101010)2.
>>The column values are ten times larger than the previous value as we move from right to left; that is, the
‘hundreds’ are ten times bigger than ‘tens’ and ‘tens’ are ten times bigger than ‘ones’.
>>In binary we just have the two symbols or values, 0 and 1. This means that in the binary number system each
column heading is twice as big as the previous one as we move from right to left
The column headings in binary, from right to left, are ‘ones’, ‘twos’, ‘fours’, ‘eights’ and so on.
The leftmost digit in a binary number is called the most significant bit (MSB) and the
rightmost digit the least significant bit (LSB).
In an 8-bit number, the MSB has decimal value of 128 and the LSB has decimal value of 1.
How to convert denary numbers
into 8-bit binary numbers and vice versa
Method1
To convert denary numbers into binary, we use the binary column heading values from the table.
We decide whether each column heading value, starting at the left-hand side, is smaller than or equal to our decimal
number.
We record 0 if it is not smaller and then compare it with the next column value.
If it is smaller than or equal to, we record 1 in the table,
subtract the number and work out the remainder.
We take that remainder and then check if it is smaller than the next column value, and repeat the process above. We
continue this process until we are left with the right-hand ‘1’ column .
Method 2
This method involves successive division by 2.
Start with the denary number, 142, and divide it by 2.
Write the result of the division including the remainder (even if it is 0)
under the 142 (that is, 142 ÷ 2 = 71 remainder 0);
Then divide again by 2 (that is,71 ÷ 2 = 35 remainder 1) and keep dividing until the result is zero.
Finally write down all the remainders in reverse order:
If we want to show this as an 8-bit binary number (as shown in Method 1), we now simply
add two 0’s from the left-hand side to give the result: 0 0 1 1 1 0 1 1.
The hexadecimal system
The hexadecimal number system is very closely related to the binary system.
Hexadecimal (sometimes referred to as simply ‘hex’) is a base 16 system and therefore needs to use 16 different ‘digits’ to
represent each value.
Because it is a system based on 16 different digits, the numbers 0 to 9 and the letters A to F are used to represent each
hexadecimal (hex) digit.
A in hex = 10 in denary, B = 11, C = 12, D = 13, E = 14 and F = 15.
Using the same method as for denary and binary, this gives the headings 16 0, 161, 162, 163, and so on.
The typical headings for a hexadecimal number with five
digits would be: Example :2 1 F 3 A
65536(164) 4096(163) 256(162) 16(161) 1(160)
2 1 F 3 A
Converting from binary to hexadecimal and from
hexadecimal to binary
Converting from binary to hexadecimal is a fairly easy process.
Starting from the right and moving left, split the binary number into groups of 4 bits.
If the last group has less than 4 bits, then simply fill in with 0s from the left.
Take each group of 4 bits and convert it into the equivalent hexadecimal digit using Table
Example 1
Convert 1 0 1 1 1 1 1 0 0 0 0 1 to Hexadecimal
First split this up into groups of 4 bits:
1011 1110 0001
Find the value of each grouped binary digits in decimal/denary
1011=11 1110=14 00001=1
Then, using Table <find the equivalent hexadecimal digits of
11, 14 and 1
Answer :11=B , E=14 and 1=1
1011,1110,0001=BE1
Converting from hexadecimal to denary and
from denary to hexadecimal
• To convert hexadecimal numbers into denary involves the value headings of each hexadecimal
digit; that is, 4096, 256, 16 and 1.
• Take each of the hexadecimal digits and multiply it by the heading values.
• Add all the resultant totals together to give the denary number. Remember that the hex digits A → F
need to be first converted to the values 10 → 15 before carrying out the multiplication.
EXAMPLE
A typical example of hex is 2 1 F 3 A
24 13 F2 31 A0
2 1 15 3 10
Example 2
Convert 1B2C in to denary
Converting Denary to Hexadecimal
To convert decimal numbers to hexadecimal:
● We check if 16 will divide into the number.
● If it does, we write down how many times using the correct hexadecimal symbol in the 16s
column.
● We then convert the remainder into its hexadecimal symbol and write it in the 1s column.
Convert 189 in decimal to hexadecimal. Convert 125 to hexadecimal
189/16=11(189-176=13) rem
11 13
B D
189= BD
Why do we use hexadecimal?
We learned that the computer processes all data in binary form. Binary numbers are very useful
in computer science, but they have disadvantages:
• It is hard for people to read and understand binary numbers.
• When you write a binary number it is easy to make a mistake.
• It is hard to spot and fix errors in binary numbers.
• Writing a binary number takes a lot of space.
People wanted numbers that were easier to understand and work with. Denary notation wasn't
suitable because converting binary to denary is difficult.
The hexadecimal notation was chosen for these reasons:
• It is very easy to turn hexadecimal into binary.
• It is very easy to turn binary into hexadecimal.
• Hexadecimal is much easier to read than binary.
• Hexadecimal numbers take up much less space than binary numbers.
Use of the hexadecimal system
• As we have seen, a computer can only work with binary data. Whilst computer scientists can work with binary, they find
hexadecimal to be more convenient to use.
• This is because one hex digit represents four binary digits.
• A complex binary number, such as 1101001010101111 can be written in hex as D2AF.
• The hex number is far easier for humans to remember, copy and work with.