Sie sind auf Seite 1von 31

# Digital Logic & Design

Lecture 02
Recap

## Last lecture discussion

 Decimal Number Systems

## Today’s lecture discussion

 Decimal-Binary Conversion
Binary to Decimal Conversion

 Sum-of-Weights
 Expression base number & weights

 Sum terms

##  Sum of non-zero terms

 Mental Arithmetic, quick method

##  Sum of weights of non-zero terms

Binary to Decimal Conversion

 Sum-of-Weights
 100112
 (1 x 24) + (0 x 23) + (0 x 22) + (1 x 21)
+ (1 x 20)
 Terms 16, 0, 0, 2 and 1
 19
Binary to Decimal Conversion

##  Add weights of non-zero terms

 Weights increase/decrease by power of 2
 100112 = 16 + 2 + 1 = 19
 1011.1012 = 8 + 2 + 1 + 1/2 + 1/8
= 11 + 5/8
= 11.625
Decimal to Binary Conversion

##  Sum-of-Weights method used in reverse

 Highest binary weight less than the decimal
number
 Subsequent smaller weights that add up to

decimal number
 Repeated division by 2
 Paper and pencil method

##  Number repeatedly divided by 2

Decimal to Binary Conversion using Sum-of-
Weights
number Weight Result after subtraction Binary Bit
392 256 392-256 = 136 1 b8
136 128 136-128 = 8 1 b7
8 64 0 b6
8 32 0 b5
8 16 0 b4
8 8 8-8 =0 1 b3
0 4 0 b2
0 2 0 b1
0 1 0 b0
Decimal to Binary Conversion
number Quotient after division Remainder after division
392 196 0 (b0)
196 98 0 (b1)
98 49 0 (b2)
49 24 1 (b3)
24 12 0 (b4)
12 6 0 (b5)
6 3 0 (b6)
3 1 1 (b7)
1 0 1 (b8)
Binary-Decimal fraction conversion

##  Binary to Decimal Conversion

 Sum-of-Weights method

##  0.11012 weights ½, ¼, 1/16

 Sum up to 0.8125

##  Decimal to Binary Conversion

 Repeated Multiplication by 2

 example
Decimal-Binary fraction conversion

##  Decimal to Binary Conversion

 Repeated multiplication by 2

## 0.8125 1.625 1 (b-1)

0.625 1.250 1 (b-2)
0.250 0.500 0 (b-3)
0.500 1.000 1 (b-4)
Binary Arithmetic

 Binary Subtraction
 Binary Multiplication
 Binary Division
 Four Basic rules for binary addition

0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

##  Addition of multiple binary numbers

Carry 1 10 1
1st Number 1 0 1 1
2nd Number 1 1 0
3rd Number 1 0 0 0
4th Number 1 1
Result 1 1 1 0 0
Binary Subtraction

## 1st digit 2nd digit Difference Borrow

0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
Binary Subtraction

Borrow 1
1st Number 1 0 1 1
2nd Number 1 1 0
Result 1 0 1
Binary Multiplication

0 0 0
0 1 0
1 0 0
1 1 1

##  Example of Binary Multiplication

Binary Multiplication

1101 (13)
x 101 (5)
1st product term 1101
2nd product term 0000
3rd product term 1101
Product 1000001 (65)
Multiplication by shifting left

##  Decimal 29 shifted left by one digit

 290
 Shift left 1 digit is multiply by 10

##  Binary 111012 (29) shifted left by one bit

 1110102 (58)
 Shift left 1 bit is multiply by 2
Binary Division

10
101 | 1101
101
011
000
11
Division by shifting right

##  Decimal 29 shifted right by one digit

 2.9
 Shift left 1 digit is divide by 10

##  Binary 111012 (29) shifted left by one bit

 1110.12 (14.5)
 Shift left 1 bit is divide by 2
Signed and Unsigned Numbers

##  Unsigned Binary Numbers

 Signed Binary Numbers
 Most significant bit represents sign

##  1 represents a negative number

2’s Complement form

##  1’s complement form

 2’s complement form

## Binary number 01101 (13)

1’s complement 10010
+ 1
2’s complement 10011 (-13)
Complement

0101 +5 0101 +5
0010 +2 1110 -2
0111 +7 0011 +3

1011 -5 1011 -5
1110 -2 0010 +2
1001 -7 1101 -3
Range of Numbers

 Maximum Range
 Number of digits
 Decimal number example
 Binary number example
 Overflow
Range of Binary Numbers

## Decimal Sign Magnitude 2’s Complement Unsigned

Number 2n-1, 2n-1 -1 2n-1, 2n-1 -1 2n, 2n - 1
0 0000 0000 000
1 0001 0001 001
2 0010 0010 010
3 0011 0011 011
4 0100 0100 100
5 0101 0101 101
6 0110 0110 110
7 0111 0111 111
Range of Binary Numbers

## Decimal Sign Magnitude 2’s Complement Unsigned

Number 2n-1-1, -(2n-1 -1) 2n-1, -2n-1
-8 1000
-7 1111 1001
-6 1110 1010
-5 1101 1011
-4 1100 1100
-3 1011 1101
-2 1010 1110
-1 1001 1111
Summary

 Sum-of-Weights

##  Decimal to Binary Conversion

 Sum-of-Weights (in reverse)

 Repeated Division by 2
Summary

 Sum-of-Weights

##  Binary to Decimal fraction conversion

 Repeated Multiplication by 2
Summary

 Binary Subtraction
 Binary Multiplication
 Multiplication by shift left operation

 Binary Division
 Division by shift right operation
Summary

 Unsigned Binary
 Signed Binary
 Sign Bit

 2’s Complement
 1’s Complement
 Range of Binary Numbers
Lecture No. 2
Number Systems