0% found this document useful (0 votes)
16 views36 pages

Lecture 2 3 Number System

number systems

Uploaded by

sohansridutta812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views36 pages

Lecture 2 3 Number System

number systems

Uploaded by

sohansridutta812
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

CKV

Digital Design
CS/EEE /ECE/INSTR F215

Lecture 2: Number systems

8/25/2020
Number systems
General use Decimal numbers : 8956

Digits used are 0 - 9

8956 = 8 x 103 + 9 x 102 + 5 x 101 + 6 x 100

Can be generalized to any decimal number

a3a2a1a0 . a-1a-2

= a3 x 103 + a2 x 102 + a1 x 101 + a0 x 100 + a-1 x 10-1 + a-2 x 10-2


25-Aug-20 CS/EEE/ECE /INSTR F215 2
Number systems
Decimal number system: Base is 10 Numbers used : 0-9

Base also called radix

Binary number system : Base is 2 Numbers used : 0-1

For example: 101.11


= 1 x 22 + 0 x 21 + 1 x 20 + 1 x 2-1 + 1 x 2-2
= 4 + 0 + 1 + 0.5 + 0.25
= 5.75
25-Aug-20 CS/EEE/ECE /INSTR F215 3
Number systems
For Base - r system (anan-1…. a1a0. a-1a-2..a-m)r

an x rn + an-1 x rn-1 …… a1 x r1 + a0 x r0 + a-1 x r-1 +…..a-m x r-m

Find the decimal equivalent of


(123.4)8 [Octal] =1 x 82 + 2 x 81 + 3 x 80 + 4 x 8-1 = 83.5

(B2.4)16 [Hexa decimal] =11 x 161 + 2 x 160 + 4 x 16-1 =??

(110101)2 [Binary]
=1 x 25 + 1x 24 + 0 x 23 + 1 x 22 + 0 x 21 + 1 x 20 = ??
25-Aug-20 CS/EEE/ECE /INSTR F215 4
CKV

Number Base conversions


Typical conversions
Base-10 to Base-r
Convert (49)10 to ()2 2 49 Remainder
2 24 1 LSB
2 12 0
2 6 0
2 3 0
2 1 1
(110001)2
0 1 MSB
8/25/2020
CKV

Number Base conversions


Typical conversions
Base-10 to Base-r
Convert (50)10 to ()2 2 50 Remainder
2 25 0 LSB
2 12 1
2 6 0
2 3 0
2 1 1
(110010)2
0 1 MSB
8/25/2020
CKV

Number Base conversions


Typical conversions
Base-10 to Base-r (fraction)
Convert (0.125)10 to Integer
()2
0.125x 2 = 0.25 0
0.25 x 2 = 0.5 0
0.5 x 2 = 1.0 1

(0.125)10 = (0.001)2 Limited to required number of digits

8/25/2020
CKV

Number Base conversions


Typical conversions
Base-10 to Base-r (fraction)
Convert (0.49)10 to ()2 Integer
0.49 x 2 = 0.98 0
0.98 x 2 = 1.96 1
0.96 x 2 = 1.92 1
0.92 x 2 = 1.84 1

(0.49)10 = (0.011111….)2 Limited to required number of digits

8/25/2020
CKV

Number Base conversions


Typical conversions
Base-r to Base-10
Convert (110110)2 to ( )10
=1 x 25 + 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20
=1 x 32 + 1 x 16 + 0 x 8+ 1 x 4+ 1 x 2 + 0 x 20
=1 x 32 + 1 x 16 + 0 x 8+ 1 x 4+ 1 x 2 + 0 x 20
=54

8/25/2020
Number systems
(B65F)16

Express the following numbers in decimal


(10110.0101)2 (1010.1010)2

(26.24)8 (16.5)16

(FAFA)16

25-Aug-20 CS/EEE/ECE /INSTR F215 10


Problems
(1) Use binary expansion to convert binary
fractions into decimals
(i) (101.1101)2 (ii) (1101.0111)2
(iii) (111.111)2 (iv) (101.01011)2
(2) Convert
(i) (13.6875)10 (ii) (32.45)10
(iii) (28.555)10 (iv) (7.0202)10 into binary
fraction
25-Aug-20 CS/EEE/ECE /INSTR F215 11
(3) Convert the following numbers with the
indicated base to decimal :

(i) (4310)5 (ii) (198)12


(iii) (735)8 (iv) (525)6

25-Aug-20 CS/EEE/ECE /INSTR F215 12


CKV

Number conversions
Other conversions

Binary to octal Octal: base 8 digits used 0 - 7

1110001010101 For Octal- 2^3, 8bit: 2^3

001 110 001 010 101

1 6 1 2 5

(1110001010101)2 (16125)8

8/25/2020
CKV

Number conversions
Other conversions

octal to binary Octal: base 8 digits used 0-7

6373
6 3 7 3

110 011 111 011

(6373)8 (110011111011)2
8/25/2020
CKV

Number conversions
Other conversions
Binary to Hexadecimal Hexa: base 16 digits used 0-F

1110001010101 4 bit, then Hexa decimal-2^4

0001 1100 0101 0101

1 C 5 5
(1110001010101)2 (1C55)16

8/25/2020
CKV

Representation of Negative Numbers

➢ Signed Magnitude
➢ Diminished radix complement
➢ Radix complement

8/25/2020
CKV

Representation of Negative Numbers


➢ Signed Magnitude 3-bit numbers Signed
magnitude
000 +0
Limitations 001 +1
010 +2
1. Two Zeros
011 +3
2. Add +2 & -1 100 -0
010 101 -1
101 110 -2
11 1
111 -3
MSB indicates Sign : 0 indicates positive, 1 indicates negative
8/25/2020
CKV

Complements
Diminished radix complement

Given a number N in base r having n digits (r-1)’s complement is


defined as (rn-1-N)

In case of decimal it is called 9’s complement

9’s complement of 865 is 103 -1 - 865 = 999 - 865 = 134

In case of binary it is called 1’s complement for 1011


24 - 1 - 1011 = 1111-1011 = 0100
1’s complement of 1011 is
(or you can simply use the
complement ~ 1 for 0 and 0 for 1)
8/25/2020
CKV

Complements

Limitations of 1’s Complement


➢ Two Zeros
➢ End-around-carry-bit addition

Add 4 & -7 Add 4 & -3

0100 0100
1000 1100
1100 1 0000
1
0001

8/25/2020
CKV
Complements Add 4 & -3

Limitations of 1’s Complement 0100


➢ Two Zeros 1100
➢ End-around-carry-bit addition 1 0000
1
0001

8/25/2020
CKV

Complements
Radix complement
Given a number N in base r having n digits r’s complement is defined as
(rn-N)
In case of decimal it is called 10’s complement

10’s complement of 865 is 103 -865 = 1000-865 = 135

10’s complement = 9’s complement + 1

In case of binary it is called 2’s complement


2’s complement of 1011 is 24 -1011 = 10000-1011 = 0101
2’s complement = 1’s complement + 1
8/25/2020
CKV

Complements
Advantages of 2’s Complement
➢ Two Zeros
➢ No End-around-carry-bit addition

Add 4 & -7 Add 4 & -3

0100 0100
1001 1101
1101 1 0001

8/25/2020
CKV

Complements

8/25/2020
CKV

Complements
Advantages of 2’s Complement
➢ Easy Implementation: Adder Subtractor M=0 adder, M=1 Subtractor

8/25/2020
CKV

Complements
Overflow in 2’s Complement

Add 4 & -3 Add -4 & -5 Add -8 & 4 Add 4 & 4

0100 1100 1000 0100


1101 1011 0100 0100
1 0001 1 0111 1100 1000

8/25/2020
CKV

Binary Codes - BCD


Consider example 7698
0000 0
0001 1 7 6 9 8
0010 2
0011 3
0100 4
BCD code
0101 5
0110 6
0111 7
1000 8
1001 9

8/25/2020
BCD and Binary comparison
(185)10 BCD = (0001 1000 0101)

Binary = (10111001)2

BCD = 12 bits, Binary = 8 bits

Some systems work directly on BCD (IBM Power6)

User enters decimal → BCD i/p→ compute in BCD → BCD o/p →


Decimal output shown to user

8/25/2020
CKV

Binary Codes - BCD


General digital systems
User enters decimal → BCD i/p→ Binary i/p → compute in binary
→ Binary o/p → BCD o/p → Decimal output shown to user

8/25/2020
CKV

Binary Codes - BCD


BCD addition
4+5 4 0100
5 0101
9 1001 Expected Result

4+8 4 0100
8 1000
1100 Is this expected Result ?

Expected answer is BCD of 12 0001 0010


8/25/2020
CKV

Binary Codes - BCD


BCD addition
4+8 4 0100
8 1000
Greater than 9 1100 Add correction of +6
0110
00010010 = To skip 6 invalid
states (10 - 15) BCDs
1 2

8/25/2020
CKV

Binary Codes - BCD


BCD addition
9+9 9 1001
9 1001
Carry out generated 1 0 0 1 0 Expected result ?
0110 Add correction of +6
00011000
1 8

After addition if carry out is generated or if sum is greater


than 9 there is need for correction
8/25/2020
CKV

Binary Codes - BCD


BCD addition

8/25/2020
CKV

Binary Codes – Gray Code

8/25/2020
CKV

Binary Codes – Gray Code

8/25/2020
CKV

Binary Codes – Gray Code

8/25/2020
CKV

Thankyou

8/25/2020

You might also like