0% found this document useful (0 votes)
11 views

Week 2 Handouts

Uploaded by

emre.aslan.2547
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)
11 views

Week 2 Handouts

Uploaded by

emre.aslan.2547
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/ 5

C

hap
ter
Representation of positive numbers 1
16

Ex: 21510=(1101 0111)2 = 127+126+025+124+023+122+121+120

Digital Design Most Signaficant Bit (MSB) Least Signaficant Bit (LSB)
2024 - 2025

Dr. Aydın Tarık Zengin


Istanbul Technical University
Faculty of Electrical and Electronics Engineering The largest postive number that can be represented by 8 bits is:
Office Number: 6312
E-mail: [email protected] (1111 1111)2=25510
The smallest postive number that can be represented by 8 bits is:
(0000 0000)2=010

C C
Some Numbers in Different Bases
hap hap
ter ter

Some Bases 1
17
1
18

Name Base Digits Decimal Binary Octal Hexa decimal

Binary 2 0,1
(Base 10) (Base 2) (Base 8) (Base 16)
00 00000 00 00
01 00001 01 01

Octal 8 0,1,2,3,4,5,6,7 02
03
00010
00011
02
03
02
03

Decimal 10 0,1,2,3,4,5,6,7,8,9 04
05
00100
00101
04
05
04
05
06 00110 06 06
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 07 00111 07 07
08 01000 10 08
09 01001 11 09
10 01010 12 0A
11 0101 1 13 0B
12 01100 14 0C
13 01101 15 0D
14 01110 16 0E
15 01111 17 0F
16 10000 20 10

C C
hap
ter
Example: 46.687510 to base 2 hap
ter
Base Conversions 1
19
 Convert whole number part (46) to binary 1
20
 46/2=23 remainder 0
 From base-r to decimal is easy  23/2=11 remainder 1
 expand the number in power series and add all  11/2=5 remainder 1
the terms  5/2=2 remainder 1
 2/2=1 remainder 0
 Reverse operation is somewhat more difficult
 1/2=0 remainder 1
 Simple idea:
 Convert the fractional part (0.6875) to binary
 divide the decimal number successively by r  0.6875*2=1.375
 accumulate the remainders.  0.375*2=0.75
 0.75*2=1.5
 If there is a fraction, then integer part and fraction
 0.5*2=1
part are handled separately.
 0*2=0

 Put two results together with a radix point


 101110.101102
C C
hap hap
ter ter
Example: 46.683110 to hexadecimal (base 16) 1
21
Conversion from base r to base decimal 1
22

 Convert 46 to base 16 Convert 101110.101102 to base 10


 46/16=2 remainder 14
 2/16=0 remainder 2 1011102 = 1·32 + 0·16 +1·8 +1·4 + 1·2 +0·1
 Convert 0.6831 to base 16 = 32 + 8 + 4 + 2
 0.6831*16=10.9296
= 46
 0.9296*16=14.8736
 0.8736*16=13.9776 0.10112 = 1/2 + 1/8 + 1/16
 0.9776*16=15.6416
= 0.5000 + 0.1250 + 0.0625
…
 Put two results together with a fraction dot = 0.6875
 2E.AEDF16

C
Conversions between Binary, Octal andhap
ter
Representation of Negative Numbers
Hexadecimal 1
23  In order to differ between positive and negative numbers the
Octal to Binary MSB is used.
 743.0568=111 100 011.000 101 1102  If “0” positive
 If “1” negative
Hexadecimal to Binary  The positive numbers that can be shown by 8 bits are
 A49.0C616=1010 0100 1001.0000 1100 01102 between 0000 0000 and 0111 1111, hence between 0 and +
127.
Binary to Octal
 1|011|100|011.000|101|110|12=1343.05648  2’s complement method is used for representation of
negative numbers.
Binary to Hexadecimal  2’s complement of a positive number shows the negative
 1|1010|0100|1001.0010|1100|0110|12=1A49.2C6816 of it.
 In order to find the 2’s complement of a number
• Octal and hexadecimal representations are more compact.  1’s complement is found: 0s are changed to 1s, 1s are
• Therefore, we use them in order to communicate with computers changed to 0s.
directly using their internal representation  1 is added to 1’s complement of the number.

C C
hap hap
ter ter
Examples for Negative Numbers 1
25
Examples for Negative Numbers 1
26

0000 0101 +5 1111 1011 -5

1’s complement 1111 1010 1’s complement 0000 0100


Addition of 1 1 Addition of 1 1

2’s complement 1111 1011 -5 2’s complement 0000 0101 +5

Negative number Pozitive number


C C
hap hap
ter ter
ARITHMETIC OPERATIONS - Binary Arithmetic 1
27
Single Bit Binary Addition with Carry 1
28

Single Bit Addition with Carry Given two binary digits (X,Y), a carry in (Z) we get the
following sum (S) and carry (C):
Multiple Bit Addition Carry in (Z) of 0: Z 0 0 0 0
X 0 0 1 1
Multiple Bit Subtraction +Y +0 +1 +0 +1
CS 00 01 01 10
Multiplication
Carry in (Z) of 1: Z 1 1 1 1
X 0 0 1 1
+Y +0 +1 +0 +1
CS 01 10 10 11

C
hap Addition of Positive and Negative

hap
C

ter ter
Addition of Positive Numbers 1
29
Numbers Represented By 2’s 1
30

Carry Complement
00 00 0 01100
X 01100 12 10110 22 Carry 00 1 0 010 0
Y +10001 +17 +10111 +23
1 1 101
X 1101 -3 0011 3
Sum 29 101 1 0 1 45
Y +0001 +1 +0010 +2
1 11 0 01 0 1
Note: Sum -2 5
Negative Positive
1. The carry input to the LSB is always ‘0’.
2. The sum of two n-bit numbers has n+1-
bits.

C C
Addition of Positive and Negative Numbers
hap Addition of Positive and Negative Numbershap
ter ter
Represented By 2’s Complement 1
31
Represented By 2’s Complement 1
32
Carry 1000 0000
Carry 111 1 0 11 1 0 0
X 0100 4 1010 -6
Y +0101 +5 +1101 -3
X 1101 -3 0011 3 Sum 1001 9 10111 -9

Y +1111 -1 +1110 -2 Is the sum negative? ignored Is the sum positive?

1 1 10 0 1 00 0 1 • Overflow occured. The largest positive number that


Sum -4 1 can be represented by 4-bits is +7. Larger numbers can
not be reprsented by 4-bits.
negative positive •The smallest negative number that can be represented
ignored ignored by 4-bits is -8. Smaller numbers can not be reprsented by
4-bits.
•The number of bits to be used in the representation of
the numbers should be decided according to the
boundaries of the inputs and the outputs of the
operations.
C C
Subtraction of Positive hap
ter
Subtraction of Numbers With hap
ter
Numbers 1
33 Sign Bit and 2’s complement 1
34
X 3 0011 0011 3
Borrow Y -1 -0001 2’s complement +1111 +(-1)
0 00 0 0 0 0 11 0 Difference 2 10010 2
X 10110 22 10110 22 ignored positive

X 3 0011 0011 3
Y - 10010 -18 - 10011 -19 Y -4 -0100 2’s complement +1100 +(-4)
Difference-1 1111 -1
Difference 0 010 0 4 0 00 1 1 3
negative
X 3 0011 0011 3
Note: The borrow input to the LSB is always ‘0’. Y -(-1) -1111 2’s complement +0001 +1
If Y>X, then X and Y are exchanged and – sign Difference 4 0100 4
is put in front of the result. positive

C C
Subtraction of Numbers With hap hap

Binary Multiplication
ter ter
Sign Bit and 2’s complement 1
35
1
36

X 1 0001 0001 1
Y -(-7) -1001 2’s complement +0111 +7 The binary multiplication table is simple:
Difference 8 Is the result negative? 1000 8 00=0 | 10=0 | 01=0 | 11=1
X -5 1011 1011 -5 Extending multiplication to multiple digits:
Y -4 -0100 2’s complement +1100 +(-4)
Multiplicand 1011
Difference -9 10111 -9
ignored
Multiplier x 101
• Overflow occured. The largest positive number that can be
Is the result positive?
Partial Products 1011
represented by 4-bits is +7. Larger numbers can not be represented by
4-bits.
0000 -
•The smallest negative number that can be represented by 4-bits is -8. 1011 - -
Smaller numbers can not be reprsented by 4-bits.
•The number of bits to be used in the representation of the numbers
Product 110111
should be decided according to the boundaries of the inputs and the
outputs of the operations.

C C
hap hap
ter ter
Binary Numbers and Binary Coding 1
37
Non-numeric Binary Codes 1
38

 Flexibility of representation Given n binary digits (called bits), a binary


 Within constraints below, can assign any binary code is a mapping from a set of represented
combination (called a code word) to any data as elements to a subset of the 2n binary
long as data is uniquely encoded.
numbers.
 Information Types Color Binary Number
 Numeric Example: A Red 000
 Must represent range of data needed binary code Orange 001
 Very desirable to represent data such that simple,
straightforward computation for common arithmetic
for the seven Yellow 010
operations permitted colors of the Green 011
 Tight relation to binary numbers rainbow Blue 101
 Non-numeric Indigo 110
 Greater flexibility since arithmetic operations not applied. Code 100 is Violet 111
 Not tied to binary numbers not used
C C
hap hap
ter ter
Number of Elements Represented 1
39
Practice 1
40

 Research for ASCII


Given n digits in radix r, there are rn distinct
elements that can be represented.  Write your name in ASCII code.
 Research for BCD
But, you can represent m elements, m < rn
 Write your school number in BCD.
Examples:
 What is odd parity?
You can represent 4 elements in radix r = 2
with n = 2 digits: (00, 01, 10, 11).  What is even parity?
You can represent 4 elements in radix r = 2
with n = 4 digits: (0001, 0010, 0100, 1000).
This second code is called a "one hot"  Any questions?
code.

 See you next week.

You might also like