Number System.pdf

728 views 23 slides Oct 15, 2022
Slide 1
Slide 1 of 23
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23

About This Presentation

Number System, Conversion, Decimal to Binary, Decimal to Octal, Decimal to Binary, Decimal to HexaDecimal, Binary to Decimal, Octal to Decimal, Hexadecimal to Decimal, Binary to Octal, Binary to Hexadecimal, Octal to Hexadecimal, BCD, Binary Addition


Slide Content

1

SWETA KUMARI BARNWAL

NUMBER SYSTEM
The language we use to communicate with each other is comprised of words and characters.
We understand numbers, characters and words. But this type of data is not suitable for
computers. Computers only understand the numbers.
So, when we enter data, the data is converted into electronic pulse. Each pulse is identified as
code and the code is converted into numeric format by ASCII. It gives each number, character
and symbol a numeric value (number) that a computer understands. So, to understand the
language of computers, one must be familiar with the number systems.
The Number Systems used in computers are:
o Binary number system
o Octal number system
o Decimal number system
o Hexadecimal number system










BASE/RADIX: The base value in a numbering system.
For example,
• In the decimal numbering system, the radix is 10.
• In the hexadecimal numbering system, the radix is 16.
• In the octal numbering system, the radix is 8.
• In the binary numbering system, the radix is 2.

Decimal (10 Symbols)
(0, 1, 2, 3…9)
Octal (8 )
(0, 1, 2, 3…7)

HexaDecimal (16 Symbols)
(0, 1, 2, 3…9, A,B,C,D,E,F)
Binary (2 Symbols)
(0 & 1)
Number System

2

SWETA KUMARI BARNWAL

Bits & Bytes:
• a "bit" is atomic: the smallest unit of storage
• A bit store just a 0 or 1
• "In the computer it's all 0's and 1's" ... bits
• Anything with two separate states can store 1 bit
• In a chip: electric charge = 0/1
• In a hard drive: spots of North/South magnetism = 0/1
• A bit is too small to be much use
• Group of 8 bits together to make 1 byte
• Everything in a computer is 0's and 1's. The bit stores just a 0 or 1: it's the smallest
building block of storage.

ASCII (American Standard Code for Information Interchange)
• ASCII is an encoding representing each typed character by a number
• Each number is stored in one byte (so the number is in 0 to 255)
• A is 65
• B is 66
• a is 96
• space is 32

ASCII stands for the "American Standard Code for Information Interchange".
It was designed in the early 60's, as a standard character set for computers and electronic
devices.
ASCII is a 7-bit character set containing 128 characters.
It contains the numbers from 0-9, the upper- and lower-case English letters from A to Z, and
some special characters.
The character sets used in modern computers, in HTML, and on the Internet, are all based on
ASCII.
The following tables list the 128 ASCII characters and their equivalent number.

3

SWETA KUMARI BARNWAL

4

SWETA KUMARI BARNWAL

Decimal to Binary
(951.205)10 →













(951.205)10 → (1110110111.0011)2
Binary to Decimal
(110101.110)2 → ( )10

5

SWETA KUMARI BARNWAL

(110101.110)2 → (53.75)10

Decimal to Octal
(98.56)10 → (142.4365)8















Octal to Decimal
(41.56)8 → ( 33.7187)10

6

SWETA KUMARI BARNWAL






Decimal to Hexadecimal
(935.126)10 → (3A7.204F)16












Hexadecimal to Decimal
(3A7.204F)16 → (935.1261)10
(2) (1) (0) (-1) (-2) (-3) (-4)  Position
3 A 7 . 2 0 4 F
x x x x x x x
16
2
16
1
16
0
16
-1
16-
2
16
-3
16
-4
768 + 160 + 7 . (.125) + (0) + (0.0009)+(0.0002)

7

SWETA KUMARI BARNWAL

Binary to/from Octal
a) Binary → Decimal → Octal
(1010101)2 → (85)10 → (125)8
(110011.110) → (51.75) → (63.6)
b) Octal → Decimal → Binary
(125) → (85) → (1010101) (1010101)
(721.25) → (465.3281) → (111010001.0101)

If no of bits = n
Number represented by that bits (N) = 2
n
– 1

Ex:

Octal System (8 symbols: 0 to 7)

N = 7
N = 2
n
– 1 = 7
n = 3

When we will convert Octal to Binary, we have required 3 bits for 1
digit.

Decimal to Binary

Binary to Decimal
2
(n-1)
……… 2
2
2
1
2
0

32 16 8 4 2 1






No ABC

4 2 1
0 0 0 0

8

SWETA KUMARI BARNWAL

1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1


(125)8 = (001 010 101) (1010101)
721.25 → (111 010 001. 010 101)
(110 011 . 110) → 63.6
(001 110 010 101 . 110 100)2 → (1625.64)
(56.54) → (000056.540000) (5600.00054)



Exercise: Octal to Binary
(128.777)
(765.154)
(5564.721)
(254.631)
(435.61)

Exercise: Binary to Octal
(110111011.111101)
(101110100.011101)
(11100011.010101)
(1010101010.1101001)

9

SWETA KUMARI BARNWAL

Hexadecimal to/from Binary
a) Hexadecimal → Decimal → Binary
(A5.9D) → (165.6132) → (10100101.1001)
(FB1.C4) → (4017.7656) → (111110110001.1100)

b) Binary → Decimal → Hexadecimal
(11110011010.10110) → (1946.6875) → (79A.B0)


Hexadecimal System (16 symbols: 0 to 9 & A B C D E F)

N = 15
N = 2
n
– 1 = 15
n = 4

When we will convert Octal to Binary, we have required 3 bits for 1
digit.

Decimal to Binary

Binary to Decimal
2
(n-1)
……… 2
2
2
1
2
0

32 16 8 4 2 1

10

SWETA KUMARI BARNWAL

No ABCD

8 4 2 1
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
A 1 0 1 0
B 1 0 1 1
C 1 1 0 0
D 1 1 0 1
E 1 1 1 0
F 1 1 1 1

a) Hexadecimal → Binary
(A5.9D) → (1010 0101 . 1001 1101) → (1010 0101.1001)
(FB1.C4) → (1111 1011 0001 . 1100 0100) → (1111 1011 0001.1100)
(1FB1.C4) → (0001 1111 1011 0001 . 1100 0100)
b) Binary → Hexadecimal
(0111 1001 1010 . 1011 0) → (79A.B0) → (79A.B0)

Q. How many bits are required to represent a number system having 128
symbols? (N 0 to 127)
N = 127
N = 2
n
-1
n = 7

11

SWETA KUMARI BARNWAL

Q. How many bits are required to represent a number system having 156
symbols?
N = 155
2
n
-1 > = N
n >= 7
n = 8
Q. How many bits are required to represent a number system having 394
symbols?
2
n
-1 > = N = 394
Let n = 8, condition is not true
Let n = 9, condition is true
n = 9
Ans.: 9
Q. How many symbols can be represented by using 10 bits?
Ans.: 1024
Q. Find the Maximum Number that can be represented by using 10 bits?
Ans.: 1023
Q. How many symbols can be represented by using 12 bits?
Ans.: 4096
Q. Find the Maximum Number that can be represented by using 9 bits?
Ans.: 511
Q. Hexadecimal to Binary
(BC5.982)
(A712.0056)
(5D8.234)
(98FE.BAF)

12

SWETA KUMARI BARNWAL

Exercise: Binary to Hexadecimal
(110111011.111101)
(101110100.011101)
(11100011.010101)
(1010101010.1101001)


We have already Covered:
Number System & Conversion between
a) Decimal to/from (Binary, Octal & Hexadecimal)
b) Binary to/from Octal & Hexadecimal

OCTAL TO/FROM HEXADECIMAL
Octal → Binary → Hexadecimal
(27.65)8 → (00010 111 . 110 10100) → (17.D4)16
(7765.6271)8 → (111 111 110 101 . 110 010 111 001) → (F F 5. C B 9)
B (11) (8421) (1011)
Hexadecimal → Binary → Octal
(FD90.5C7) → (001111 1101 1001 0000 . 0101 1100 0111) → (176620.2707)8

Ex:
(12FD.97C) (9532.4471) (10DE4.10B) (7AB.F9EB)

(710.554) (5517.346) (7712.354) (1275.2606)
BCD (Binary Coded Decimal)
Another process for converting decimal numbers into their binary equivalents.
• It is a form of binary encoding where each digit in a decimal number is represented
in the form of bits.
• This encoding can be done in either 4-bit or 8-bit (usually 4-bit is preferred).

13

SWETA KUMARI BARNWAL

• It is a fast and efficient system that converts the decimal numbers into binary
numbers as compared to the existing binary system.
• These are generally used in digital displays where is the manipulation of data is
quite a task.
• Thus, BCD plays an important role here because the manipulation is done treating
each digit as a separate single sub-circuit.

In the BCD numbering system, the given decimal number is segregated into chunks of four
bits for each decimal digit within the number. Each decimal digit is converted into its direct
binary form (usually represented in 4-bits).
DECIMAL NUMBER BCD
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001

(852.371)10 → (1000 0101 0010 . 0011 0111 0001)BCD
8 → 1000
5 → 0101
2 → 0010
3 → 0011
7 → 0111
1 → 0001

14

SWETA KUMARI BARNWAL

Arithmetic System
a) Addition
1+0 = 1
0+0 = 0
1+1 = 10 → {(1*2
1
) + (0*2
0
) = 2}
1+1+1 = 11 → {(1*2
1
) + (1*2
0
) = 3}
1+1+1+1 = 100 → {(1*2
2
) + (0*2
1
) + (0*2
0
) = 4}


1100
+1011
10111

11111
+11111
111110
12
12
24

99
99
198

15

SWETA KUMARI BARNWAL

Ex:
1011+1111+1100+1001
1111+1111+1111+1111 = 111100
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1


95
98


1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1


1100+0011
10101111+10001111 = 111111110, 100111110
10101111
10001111

11000011 + 1111100
8 4 2 1
0 1 0→ 2, 011/11 → 3, 100

16

SWETA KUMARI BARNWAL

1+ 1 = 2, 1+1+1 = 3, 1+1+1+1=4
1+1 = 10, 1+1+1 = 11, 1+1+1+1=100

Ex:
a) 1011101110 +1111000110
b) 1111100001+11000110010+10001110101+1011011111=
1000101100111

01111100001
11000110010
10001110101
01011011111




b) Subtraction: (9-5 = 4, 5-9 = -4)
A B Difference Borrow
0 0 0 0
0 1
1 0 1 0
1 1 0 0

4
+5
9
-5
4
1+1 = 10 -1= 1
1+1=2-1=1
1+1=10-1= 1

17

SWETA KUMARI BARNWAL

10
-1

1 1 1 1
1 0 0 1




5000
1925



100 → 4

2
n-1
………..2
1
, 2
0

11111111100000 → 16352
10000111000011 → 08643
07709


(2
13
*0)+ (2
12
*1)+ (2
11
*1)+ (2
10
*1)+ (2
9
*1)+ (2
8
*0)+
(2
7
*0)+ (2
6
*0)+ (2
5
*0)+ (2
4
*1)+ (2
3
*1)+ (2
2
*1)+
(2
1
*0)+ (2
0
*1) =
0+4096+2048+1024+512+0+0+0+16+8+4+0+1=7709

Ex:
a) 110011101 – 100101011



b) 101010101-010101010
c) 111111000-111000111

18

SWETA KUMARI BARNWAL

d) 11001100-10101011



c) Multiplication:
1001
1000



1111
1111 11000001 (11100001)





Ex:
i) 11010*11100
ii) 11101*11111
iii) 111111*101010
iv) 101010*1010101
v) 111111*101

d) Division:
1001/1000

1000

19

SWETA KUMARI BARNWAL












Ex:
i) 11111/1100
ii) 101010/111
iii) 1110011/1010
iv) 1111010/1100
1876→ 10
762 → 8
1011 → 2
98A→ 16

1’s Complement:- A binary no system used to write the -ve no.
Method to write this no.-
transforming the 0 bit to 1 and the 1 bit to 0
Ex:-
1010111110 → 0101000001 = 1111111111
9 → 1001
(-9) → 0110 (in 1’s complement)
129 → 10000001 (2048 1024 512 256 128 64 32 16 8 4 2 1)
Write (-129) → using 1’s complement → 01111110
Write 148 in 1’s complement → (10010100) → 01101011 (-148)

20

SWETA KUMARI BARNWAL

NOTE: If we take complement of any no in two times, then we will get the
original no.
Write in 1’s Complement: (HW)
a) 1110001010 → 0001110101
b) 11111000011
c) 10101010101
d) 1001111000
e) 256 → 011111111 → (100000000)
f) -412 → (412→110011100) → (-412 → 001100011)
g) 98
h) -567

2’s Complement
101010111 → (1’s Complement) 010101000 +1 →(2’s Complement)
010101001

010101001 → 101010110+1 → 101010111

10110110 → 01001001 → 10110110

256 → (100000000) (Binary)
-256 → (011111111) (in 1’s Complement)
-256 → (011111111+1 → 100000000) (in 2’s Complement)
011111111
1


-412 (412→110011100 → Binary) → (-412 → 001100011 → 1’s Complement)
→ (-412 → 001100100 → 2’s complement)
001100100 → 110011011+1 → 110011100

21

SWETA KUMARI BARNWAL


Ex:
a) 298 → 100101010 → (-298 → 011010101 → 1’s) (-298 →
011010110 → 2’s)
b) -298 → 011010110 (011011000)
c) 97
d) -492
e) 187
f) -299
g) 100011101
h) 111001111
i) 100000010


Sign Representation

-355 → (355)

+355 → (355)

(28 → 000011100)
(-28 → 100011100)

28 0
Sign
00011100
(Magnitude

-28 1
Sign
00011100
(Magnitude

(No. of bits: 1, 2, 4, 8, 16…….)


5 (+5) → 0101 → 0 0101
-5 → 0101 (5) → 1 0101

37 → 00100101 (2
n
no of bits) 32 16 8 4 2 1

22

SWETA KUMARI BARNWAL






54 → 110110 (00110110) (1101 0110)
129 → 10000001
37 →
0 00100101 000100101

-37 →
1 00100101 100100101


453 → 111000101 → 0000000111000101
0 0000000111000101 00000000111000101

-453
1 0000000111000101 10000000111000101

Ex: (HW)
Write these numbers in 1’s, 2’s Compliment & Sign Representation
a) 137 & -137
b) 98 & -98
c) 266 & -266
d) 32 & -32
e) 78 & -78
The given binary no is in sign representation. Find the magnitude & Sign.
a) 1 1001 = (-9)

23

SWETA KUMARI BARNWAL

b) 0 1101 (+13)
c) 0 00111010 (+58)
d) 1 00111111 (-63)
e) 1 11111111 (-255)
The given binary no (10010) is in sign representation. Find the magnitude
& Sign.
Ans: (-2)

Overflow:
1111
+1111
11110
10111
0111
11110

2
n
→ No of symbols
2
n
-1

→ Maximum no represented by n bits.
n → bits number
n = 1
No of symbols = 2
1
= 2 ( 0, 1)
Maximum no represented by 1 bits = 2
1
-1

= 1
n = 2
No of symbols = 2
2
= 4 ( 00, 01,10, 11)
Maximum no represented by 2 bits = 2
2
-1

= 3
n = 5
No of symbols = 2
5
= 32 ( 00000, 00001, 00010……… 11111)
Maximum no represented by 5 bits = 2
5
-1

= 31