Week 2 Handouts
Week 2 Handouts
hap
ter
Representation of positive numbers 1
16
Digital Design Most Signaficant Bit (MSB) Least Signaficant Bit (LSB)
2024 - 2025
C C
Some Numbers in Different Bases
hap hap
ter ter
Some Bases 1
17
1
18
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
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
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
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 00=0 | 10=0 | 01=0 | 11=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