Number System
Number System
Number System
Chapter 3 (part 1)
TOPICS
• Brief history
• Number System
• Conversion
❖ Decimal → Binary, Octal, Hexadecimal
❖ Binary, Octal, Hexadecimal → Decimal
❖ Binary → Octal, Hexadecimal
❖ Octal → Hexadecimal
❖ Conversion of Fractional numbers
• 2’s Complement
• Computer Coding
❖ Binary Coded Decimal [IBM, 1928 – 4 bits]
❖ Binary Code [Gottfried Leibniz, 1779]
❖ Octal Code [King of Sweden 10th Charls Emanuel Sweedenborg, 1716 – 3bits]
❖ Decimal Code [Hindu-Arabic, 1911]
❖ Alphanumeric Code [IBM, 1837 – 4 bits]
❖ ASCII (American Standard Code for Information Interchange)
[ANSI (AmericanNational Standards Institute), 1963 – 7 bits]
[ASCII-7; Robert William Bimar, 1965 – 8bits]
❖ EBCDIC (Extended Binary Coded Decimal Interchange Code) [IBM, 1950-64 – 8 bits]
❖ Unicode [Apple/Xerox; 1987 – 16 bits]
❖ Morse Code [Samuel FB Morse, 1837 – signal on/off]
❖ Gray code [Frank Gray, 1947 – image of binary]
• BC 4000– Sumerian people used to count large numbers using mark on soil.
This system is called Tally system.
• BC 3400 – Egyptian people introduced Hieroglyphics using various written
signs or numbers like one mark for 1, two marks for 2, nine marks for 9, a
special mark for 10.
Roman people introduced their own number system using Romanian
symbol like I, II,III, IV, V, VI, VII, VIII, IX, X
• BC 2000 – Babylon Civilization used counting system based on 60. Still we
use this system for time counting like 60 seconds equal 1 min.
• BC 900 – Indian people used 0 for their calculation. Even they have done
also the procedure of addition, subtraction, multiplication, division using 0.
[before that people had the idea of zero but they did not actually used the
number 0. In Egypt, if there was no balance in a transaction, they
presented that as “NAFAR” that means zero]
• BC 500-200 – Indian mathematician Pingola invented binary system for
calculation which looks like MORSE code at now.
• BC 498 – Indian mathematician Arjovat used modern number system in one
of his novels that denotes today’s positional number system
• BC 400 – Ten based number system was developed in India[ten based
number system was introduced by 27 Greek alphabets]. After that
mathematicians did huge research and played a vital role to spread the
system. this system is familiar as the Hindu-Arabic number system.
• The concept of fraction was introduced in Egypt.
• At first the Greek philosopher Aristotle explained the concept of Infinity.
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13
20 10100 24 14
21 10101 25 15
22 10110 26 16
23 10111 27 17
24 11000 30 18
25 11001 31 19
26 11010 32 1A
28 11100 34 1C
29 11101 35 1D
30 11110 36 1E
31 11111 37 1F
32 100000 40 20
• Step 1 − Divide the decimal number to be converted by the value of the new base.
• Step 2 − Get the remainder from Step 1 as the rightmost digit (least significant digit) of
new base number.
• Step 3 − Divide the quotient of the previous divide by the new base.
• Step 4 − Record the remainder from Step 3 as the next digit (to the left) of the new base
number.
Repeat Steps 3 and 4, getting remainders from right to left, until the quotient becomes zero in
Step 3.
The last remainder thus obtained will be the Most Significant Digit (MSD) of the new base
number.
EXAMPLE −
Decimal Number: 2910
Converting to Binary Equivalent −
Step 1 29 / 2 14 1
Step 2 14 / 2 7 0
Step 3 7/2 3 1
Step 5 1/2 0 1
EXAMPLE −
Decimal Number: 103710
Converting toOctal Equivalent −
Step 2 129/ 8 16 1
Step 3 16 / 8 2 0
Step 4 2/8 0 2
Step 3 38 / 16 2 6
Step 4 6 / 16 0 6
Now to convert any Fractional decimal number into any other number system
following steps are needed
• Step 1: Multiple the decimal fractional number by the base of required number
system
• Step 2: reserve the integer part of the product. If no integer is found then reserve
0
• Step 3: Multiple the rest fractional part of the product again by the same base
again
• Step 4: repeat step 2 and step 3 again and again until the product becomes 0.
now the reserved integer parts will be the required number of the new number
system from begin to end.
0.625 x 2= 1.25 1
0.25 x 2= 0.50 0
0.50 x 2= 1.0 1
0x2=0 0 (LSB)
Now, write these resultant integer part, this will be 0.11010 which is equivalent binary
fractional number of decimal fractional 0.8125.
Step 1 128/ 16 8 0
Step 4 6 / 16 0 6
0 x 16= 0 0 (LSB)
So (.375)10= (.60)16
• Step 1 − Determine the column (positional) value of each digit (this depends on
the position of the digit and the base of the number system).
• Step 2 − Multiply the obtained column values (in Step 1) by the digits in the
corresponding columns.
• Step 3 − Sum the products calculated in Step 2. The total is the equivalent value
in decimal.
EXAMPLE
Binary Number − 111012
Calculating Decimal Equivalent −
EXAMPLE
Octal Number − 258
Calculating Decimal Equivalent −
EXAMPLE
Hexadecimal Number –E3B16
Calculating Decimal Equivalent −
Suppose we have the following binary number of: 1101.01112, what will be its
decimal number equivalent?
1101.0111
(21. 2 1 )8
= 2 x 81 + 1 x 80 + 2 x 8-1 + 1 x 8-2
= 2 x 8 + 1 x 1 + 2 x (1 / 8) + 1 x (1 / 64)
= 16 + 1+ (0. 2 5) + (0. 0 1 5 6 2 5)
= 17 + 0. 265625
= 17. 265625
EXAMPLE
A.28F5C 6
= 10.1599...
= 10.16
• Step 1 − Divide the binary digits into groups of three (for octal) / four (for
Hexadecimal) starting from the right.
• Step 2 − Convert each group of binary digits to decimal number.
By ASIFUL HAQUE KHAN ABIR Page 11
EXAMPLE
Binary Number − 101012
Calculating Octal Equivalent −
Step 2 101012 28 5 8
• Step 1 − Convert each octal digit to a 3-digit binary number and combine these
numbers.
• Step 2 –Follow the steps to convert binary to hexadecimal
5 2 7 . 3 7 58
= 101 010 111 . 011 111 101 [ converted into binary ]
= 101010111.011111101
= 0001 0101 0111. 0111 1110 1000 [ 4bit binary group ]
= 157.375 16 [ each 4bit binary converted to decimal ]
( 37B.2D)16
= 0011 0111 1011 . 0010 1101
= 001101111011.00101101
=001 101 111 011 . 001 011 010
=1573.132 8
Homework
0 0 0 0 1 0 1 0
Sign bit
Numbers
2610 = 110102
0 0 0 1 1 0 1 0
So,
+ 26 = 0 0 0 1 1 0 1 0
1s’ complement = 1 1 1 0 0 1 0 1
2’s complement = + 1
11100110
At the time of 2’s complement addition , the number of bits for each number must be
equal (8bits). In this respect, it can be explained by the rules below :
22 + 9 = 31
+22 : 0 0 0 1 0 1 1 0
+ 9 : 0 0 0 0 1 0 0 1
+ 31 : 0 0 0 1 1 1 1 1
22 - 13 = 9
22 + (-13) = 9
+13 : 0 0 0 0 1 1 0 1
1’s
complement : 1 1 1 1 0 0 1 0
2’s
complement : + 1
-13 : 1 1 1 1 0 0 1 1
+22 : 0 0 0 1 0 1 1 0
-13 : 1 1 1 1 0 0 1 1
+9 : 1 0 0 0 0 1 1 0 1
-22 + 13 = - 9
22 : 0 0 0 1 0 1 1 0
13 : 0 0 0 0 1 1 0 1
+22 : 0 0 0 1 0 1 1 0
1’s
complement : 1 1 1 0 1 0 0 1
2’s
complement : + 1
-22 : 1 1 1 0 1 0 1 0
- 22 : 1 1 1 0 1 0 1 0
+13 : 0 0 0 0 1 1 0 1
- 9 : 1 1 1 1 0 1 1 1
Here sign bit (8th bit) of the result is 1; result is negative and again if it makes the
summation of the result of 2’s complement , it will be found 0 0 0 1 0 0 1 = 9 . so the
result is the negative value of 9 .
BCD code is a 4 bit code. BCD code is available converting each one number from 0 to
9 into 4 bit binary. For example-
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
4. Alphanumeric Code
Code that used for alphabet, number, different mathematical sign (+, -, *, - ) and some
more special symbol (!,@,#, %, &, $) is called alphanumeric code. Some popular
alphanumeric codes are:
• ASCII Code
• EBCDIC Code
• Unicode
Full version of ASCII code is American Standard Code for Information Interchange.
This is the most common 7 bit code. 3 bits of which at left most position are considered
as zone bits and 4 bits from right most position are considered as number.
For example
A = 01000001
1 0 0 0 0 0 1
But it could be converted into 8 bit ASCII code by adding a parity bit to the left most
position
A = 1 1 0 0 0 0 0 1
This table is only to give you an idea how ASCII codes are used .
Parity bit : The extra bit added to binary data or code for transferring it from sender to
receiver correctly is called the parity bit . It is used basically for diagnosis of error while
data transformation .
Full version of EBCDIC code is Extended Binary Coded Decimal Information Code.
It's a 8 bit code. It is also known as extended EBCDIC code.
2* means 256 numbers and special symbols could be indicated using this code.
In this code 1111 zone bit for 0 to 9 numbers, 1100, 1101 and 1110 zone bits for A to Z
alphabet and for special symbols 0100, 0101, 0110 and 0111 zone bits are used. After
converting decimal number using 8421 code, 1111 zone bit is added with each number
to the left position to express EBCDIC code.
For example,
Now the EBCDIC code of 5 would be 11110101. Here 1111 zone bit is added to the left
most position.
7. Unicode
To include world's all languages in a computer code, large companies create a standard
which is known as Unicode. Unicode is short for universal code. At present Unicode is
started to use through worldwide side by side with the typical ASCII code. Unicode is a
16 bit code. It is used to express different kinds of characters and texts. 216 = 65,536
numbers could be indicated using Unicode. For the people of the whole world of all
languages, a group of computer engineers from Apple computer corporation and Xerox
corporation jointly invented Unicode in 1991 as they can computing easily in their native
language.
Advantages of Unicode