Number System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

NUMBER SYSTEM

Chapter 3 (part 1)

TOPICS
• Brief history

• Number System

• Introduction to different kinds of Number System


❖ Decimal
❖ Binary
❖ Octal
❖ Hexadecimal
• Addition, Subtraction, Multiplication, Division

• 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]

By ASIFUL HAQUE KHAN ABIR Page 1


HISTORY OF INVENTING NUMBERS

• 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.

By ASIFUL HAQUE KHAN ABIR Page 2


Decimal Binary Octal Hexadecimal
Base-10 Base-2 Base-8 Base-16

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

By ASIFUL HAQUE KHAN ABIR Page 3


27 11011 33 1B

28 11100 34 1C

29 11101 35 1D

30 11110 36 1E

31 11111 37 1F

32 100000 40 20

Conversion of Number System:

Rule 1: Decimal to Binary/Octal/Hexadecimal

• 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 Operation Result Remainder

Step 1 29 / 2 14 1

Step 2 14 / 2 7 0

Step 3 7/2 3 1

By ASIFUL HAQUE KHAN ABIR Page 4


Step 4 3/2 1 1

Step 5 1/2 0 1

As mentioned in Steps 2 and 4, the remainders have to be arranged in the reverse


order so that the first remainder becomes the Least Significant Digit (LSD) and the last
remainder becomes the Most Significant Digit (MSD).
Decimal Number − 2910 = Binary Number − 111012.

EXAMPLE −
Decimal Number: 103710
Converting toOctal Equivalent −

Step Operation Result Remainder

Step 1 1037 / 8 129 5

Step 2 129/ 8 16 1

Step 3 16 / 8 2 0

Step 4 2/8 0 2

As mentioned in Steps 2 and 4, the remainders have to be arranged in the reverse


order so that the first remainder becomes the Least Significant Digit (LSD) and the last
remainder becomes the Most Significant Digit (MSD).
Decimal Number − 103710 = Octal Number –20158.

By ASIFUL HAQUE KHAN ABIR Page 5


EXAMPLE 3 −
Decimal Number: 987110
Converting toHexadecimal Equivalent −

Step Operation Result Remainder

Step 1 9871/ 16 616 15=F

Step 2 616 / 16 38.5 8

Step 3 38 / 16 2 6

Step 4 6 / 16 0 6

As mentioned in Steps 2 and 4, the remainders have to be arranged in the reverse


order so that the first remainder becomes the Least Significant Digit (LSD) and the last
remainder becomes the Most Significant Digit (MSD).
Decimal Number − 987110 = Binary Number – 668F16

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.

By ASIFUL HAQUE KHAN ABIR Page 6


Example − Convert decimal fractional number 0.8125 into binary number.
Since given number is decimal fractional number, so by using above algorithm
performing short multiplication by 2 with integer part.

Multiplication Resultant integer part (R)

0.8125 x 2= 1.625 1 (MSB)

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.

Example − Convert decimal fractional number 128.375 into Hexadecimal number.


Since given number is decimal fractional number, first we need to convert the integer
part of the number (123) to hexadecimal

Step Operation Result Remainder

Step 1 128/ 16 8 0

Step 4 6 / 16 0 6

So, 12810 =8016

By ASIFUL HAQUE KHAN ABIR Page 7


now using above algorithm performing short multiplication by 16we need to convert the
fractional part (.375) then we combine those parts.

Multiplication Resultant integer part (R)

0.375 x 16= 6.0 6 (MSB)

0 x 16= 0 0 (LSB)

So (.375)10= (.60)16

The equivalent Hexadecimal number of (128.375)10 = (80.6)16

Rule 2: Binary/Octal/Hexadecimal to Decimal

• 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 −

Step Binary Number Decimal Number

Step 1 111012 ((1 × 24) + (1 × 23) + (1 × 22) + (0 × 21) + (1 × 20))10

By ASIFUL HAQUE KHAN ABIR Page 8


Step 2 111012 (16 + 8 + 4 + 0 + 1)10

Step 3 111012 2910

Binary Number − 111012 = Decimal Number − 2910

EXAMPLE
Octal Number − 258
Calculating Decimal Equivalent −

Step Octal Number Decimal Number

Step 1 258 ((2 × 81) + (5 × 80))10

Step 2 258 (16 + 5 )10

Step 3 258 2110

Octal Number 258 = Decimal Number 2110

EXAMPLE
Hexadecimal Number –E3B16
Calculating Decimal Equivalent −

By ASIFUL HAQUE KHAN ABIR Page 9


Step Hexadecimal Number Decimal Number

Step 1 E3B16 ((14 × 162) + (3 × 161) + (11 × 160))10

Step 2 E3B16 (3584 + 48 + 11 )10

Step 3 E3B16 364310

Hexadecimal Number – E3B16= Decimal Number −364310

For the conversion of a fractional (other based) number to Decimal number


system we need to follow the same system but the positional weights for each of
the digits is considered giving its decimal equivalent (becomes negative)

Suppose we have the following binary number of: 1101.01112, what will be its
decimal number equivalent?
1101.0111

= (1×23) + (1×22) + (0×21) + (1×20) + (0×2-1) + (1×2-2) + (1×2-3) + (1×2-4)


= 8 + 4 + 0 + 1 + 0 + 1/4 + 1/8 + 1/16
= 8 + 4 + 0 + 1 + 0 + 0.25 + 0.125 + 0.0625
= 13.437510

By ASIFUL HAQUE KHAN ABIR Page 10


EXAMPLE

Convert (2 1. 2 1 )8= (? )10

(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

CONVERT A.28F5C16 = (? )10

A.28F5C 6

=Ax160 + 2x16-1 + 8x16-2 + Fx16-3 + 5x16-4 + Cx16-5

= 10x160 + 2x16-1 + 8x16-2 + 15x16-3 + 5x16-4 + 12x16-5

= 10 + 0.125 + 0.03125 + 0.0036621 + 0.000076 + 0.000011

= 10.1599...

= 10.16

Rule 3: Binary to Octal/Hexadecimal and vice versa

• 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 Binary Number Octal Number

Step 1 101012 010 101

Step 2 101012 28 5 8

Step 3 101012 258

Binary Number − 101012 = Octal Number − 258


EXAMPLE
Binary Number − 111012
Calculating hexadecimal Equivalent −

Step Binary Number Hexadecimal Number

Step 1 111012 0001 1101

Step 2 111012 110 1310

Step 3 111012 1D16

Binary Number − 111012 = Hexadecimal Number – 1D16

By ASIFUL HAQUE KHAN ABIR Page 12


AGAIN Octal/Hexadecimal to Binary
Steps
• Step 1 − Convert each octal digit to a 3-digit binary number / hexadecimal digit
to a 4-digit binary number.
• Step 2 − Combine all the resulting binary groups (of 3 digits each) into a single
binary number.
EXAMPLE
Octal Number − 258
Calculating Binary Equivalent −

Step Octal Number Binary Number

Step 1 258 210 510

Step 2 258 0102 1012

Step 3 258 0101012

Octal Number − 258 = Binary Number − 101012


EXAMPLE
Hexadecimal Number − B516
Calculating Binary Equivalent −

Step Hexadecimal Number Binary Number

Step 1 B516 1110 510

Step 2 B516 10112 01012

Step 3 B516 101101012

Hexadecimal Number − B516 = Binary Number − 1011010122

By ASIFUL HAQUE KHAN ABIR Page 13


Rule 3: Octal to Hexadecimal and vice versa

• 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

Example : Convert ( 527.375)8into hexadecimal number.

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 ]

Example : Convert ( 37B.2D)16 into octal number.

( 37B.2D)16
= 0011 0111 1011 . 0010 1101
= 001101111011.00101101
=001 101 111 011 . 001 011 010
=1573.132 8

Homework

1. Convert 14610 into a binary number system


2. Convert 1A716 into the decimal number system
3. Convert (110010)2 into octal number system
4. Convert DA216 into the binary number system
5. Convert 46528 into the binary number system
6. Convert 247810 into the Hexadecimal number system
7. Convert 39810 into the hexadecimal number system
8. Convert 111102 into the decimal number system

By ASIFUL HAQUE KHAN ABIR Page 14


Signed Number
8 bit makes up 1 byte. Number in computer is organized in memories of 8 bits (or
multiple of 8) . If the number is smack , then digit is filled from right side and the empty
rooms of left side are filled with 0. While the 8th bit is used to determine whether the
number is positive or negative. If the bit is 0, that means the number is positive and for
1 the number is considered negative.

0 0 0 0 1 0 1 0
Sign bit
Numbers

Method used for the formation of 2’s complement

In 1945, Von Newman proposed to use 2’s complement in EDSAC


computer.

26 in 2’s complement form .

2610 = 110102

this number is assembled in the register in this way :

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

By ASIFUL HAQUE KHAN ABIR Page 15


2’s Complement Addition

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 :

• Do ordinary binary summation


• If subtraction is to be done , perform addition after converting the number by 2’s
complement [ like, 20 - 12 → 20 + (-12) ]
• Carry is to be deducted (if any)
• If the result is negative ( sign bit 1 represents negative number) then it is to be
converted by 2’s complement
• If two numbers are subtracted, and their signs are different then addition is to be
performed after the negative number being converted into positive by 2’s
complement [ like, 20 – ( - 10 ) → 20 + 10 ]

Two positive numbers:

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

One positive and one negative number:

22 - 13 = 9

22 + (-13) = 9

Here 13 is to be converted to -13 by 2’s complement

+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

By ASIFUL HAQUE KHAN ABIR Page 16


Now sum of +22 and -13

+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

Here carry 1 will not be considered.

So the result will be +9 = 0 0 0 0 1 1 0 12

One negative and one positive number:

-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

Now sum of -22 and 13

- 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 .

By ASIFUL HAQUE KHAN ABIR Page 17


COMPUTER CODING
Every alphabet, number or special symbol used in computer system is required to
explain differently for CPU. To do so all of those are needed to convert into binary
codes such as 0 and 1 and arranged differently to create unique signal. These unique
signals are called code. Coding is required for data input. Again after processing output
is decoded. In this system codes are converted into alphabet, number or symbol. On
basis of application codes are divided differently.
Name of some most used code are stated below:

• Octal Code • Hexadecimal Code

• BCD Code • Alphanumeric Code

• ASCII Code • EBCDIC Code

• Unicode • Morse Code

Recently ASCII code and Unicode are mostly used.


1. Octal Code
Octal code is 3 bit binary code. Another word binary code that contains 3 bit is known
as octal code. Large binary number could be easily expressed as a short symbol with
the help of octal code. Octal code is used to connect with computer and
microprocessor.
For example : (46)10 = (10110)2 = (56) 8 = 101110 (Octal Code)
2. Hexadecimal Code
Hexadecimal code is 4 bit binary code. Another word binary code that contains 4 bit is
known as hexadecimal code. Large binary number could be easily expressed as a short
symbol with the help of hexadecimal code. Hexadecimal code is used to connect with
computer and microprocessor.
For example : (37)10 = (25) 16 = 00100101 (hexadecimal Code)
3. BCD Code
The full version of BCD is Binary Coded Decimal. BCD code is used to express binary
number into decimal number. 4 bit binary number is required to indicate every 10
numbers from 0 to 9. Using 4 bit ' means 16 different conditions could be indicated.

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-

By ASIFUL HAQUE KHAN ABIR Page 18


Decimal BCD

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

For Example: ASCII - 7 is an alphanumeric code. 27 or 128 symbols could be indicated


using this code. Likewise 28 or 256 symbols could be indicated.

By ASIFUL HAQUE KHAN ABIR Page 19


5. ASCII Code

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

Zone bit Number bit

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

Parity bit Zone bit Number bit

Char Dec Binary Char Dec Binary Char Dec Binary

! 033 00100001 A 065 01000001 a 097 01100001

" 034 00100010 B 066 01000010 b 098 01100010

# 035 00100011 C 067 01000011 c 099 01100011

$ 036 00100100 D 068 01000100 d 100 01100100

% 037 00100101 E 069 01000101 e 101 01100101

& 038 00100110 F 070 01000110 f 102 01100110

' 039 00100111 G 071 01000111 g 103 01100111

( 040 00101000 H 072 01001000 h 104 01101000

) 041 00101001 I 073 01001001 i 105 01101001

* 042 00101010 J 074 01001010 j 106 01101010

+ 043 00101011 K 075 01001011 k 107 01101011

, 044 00101100 L 076 01001100 l 108 01101100

By ASIFUL HAQUE KHAN ABIR Page 20


- 045 00101101 M 077 01001101 m 109 01101101

. 046 00101110 N 078 01001110 n 110 01101110

/ 047 00101111 O 079 01001111 o 111 01101111

0 048 00110000 P 080 01010000 p 112 01110000

1 049 00110001 Q 081 01010001 q 113 01110001

2 050 00110010 R 082 01010010 r 114 01110010

3 051 00110011 S 083 01010011 s 115 01110011

4 052 00110100 T 084 01010100 t 116 01110100

5 053 00110101 U 085 01010101 u 117 01110101

6 054 00110110 V 086 01010110 v 118 01110110

7 055 00110111 W 087 01010111 w 119 01110111

8 056 00111000 X 088 01011000 x 120 01111000

9 057 00111001 Y 089 01011001 y 121 01111001

: 058 00111010 Z 090 01011010 z 122 01111010

; 059 00111011 [ 091 01011011 { 123 01111011

< 060 00111100 \ 092 01011100 | 124 01111100

= 061 00111101 ] 093 01011101 } 125 01111101

> 062 00111110 ^ 094 01011110 ~ 126 01111110

? 063 00111111 _ 095 01011111 _ 127 01111111

@ 064 01000000 ` 096 01100000

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 .

By ASIFUL HAQUE KHAN ABIR Page 21


6. EBCDIC Code

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,

BCD for 5 = 0101.

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

1. It's a code of 16 bit, so can represent 65,536 unique symbols.


2. All major or minor languages in the world can be coded into computers.
3. Total 16 bits can be used to code the character.
4. Unicode is compatible with the ASCII code. That is the 1st 256 unicode is same
like ASCII code.
5. Unicode can be changed to other standard code.

By ASIFUL HAQUE KHAN ABIR Page 22

You might also like