CAO - Unit IV Notes
CAO - Unit IV Notes
2) 1's complement
3) 2's complement
• In all three formats, MSB=0 for +ve numbers & MSB=1 for -ve numbers.
In sign-and-magnitude system,
negative value is obtained by changing the MSB from 0 to 1 of the corresponding positive value.
-5 is represented by 1101.
negative values are obtained by complementing each bit of the corresponding positive number.
(In other words, the operation of forming the 1's complement of a given number is equivalent to
subtracting that number from 2n-1).
forming the 2's complement of a number is done by subtracting that number from 2n.
For ex, -5 is obtained by complementing each bit in 0101 & then adding 1 to yield 1011. (In other words,
the 2's complement of a number is obtained by adding 1 to the 1's complement of that number).
• 2's complement system yields the most efficient way to carry out addition/subtraction operations.
ADDITION & SUBTRACTION OF SIGNED NUMBERS
• Following are the two rules for addition and subtraction of n-bit signed numbers using the 2's
complement representation system (Figure 1.6).
Rule 1:
To Add two numbers, add their n-bits and ignore the carry-out signal from the MSB position.
Rule 2:
To Subtract two numbers X and Y (that is to perform X-Y), take the 2's complement of Y and then
add it to X as in rule 1.
• When the result of an arithmetic operation is outside the representable-range, an arithmetic overflow is
said to occur.
• To represent a signed in 2's complement form using a larger number of bits, repeat the sign bit as many
times as needed to the left. This operation is called sign extension.
• In 1's complement representation, the result obtained after an addition operation is not always correct.
The carry-out(cn) cannot be ignored. If cn=0, the result obtained is correct. If cn=1, then a 1 must be
added to the result to make it correct.
• For example: If we add two numbers +7 and +4, then the output sum S is 1011( 0111+0100), which is
the code for -5, an incorrect result.
1) Overflow can occur only when adding two numbers that have the same sign.
2) The carry-out signal from the sign-bit position is not a sufficient indicator of overflow when
adding signed numbers
Half Adder
A Half-adder circuit needs two binary inputs and two binary outputs. The input variable shows the
augend and addend bits whereas the output variable produces the sum and carry.
o 'x' and 'y' are the two inputs, and S (Sum) and C (Carry) are the two outputs.
o The Carry output is '0' unless both the inputs are 1.
o 'S' represents the least significant bit of the sum.
S = x'y+xy', C = xy
This circuit needs three binary inputs and two binary outputs.
Two of the input variable 'x' and 'y', represent the two significant bits to be added.
The third input variable 'z', represents the carry from the previous lower significant position.
The outputs are designated by the symbol 'S' for sum and 'C' for carry.
Adder Circuits
1’s complement invert each digit 10 and 01. There is no unsigned representation of negative
numbers. Add 1 to 1’s complement to get 2’s complement. Negative numbers are represented in 2’s
complement form .Only negative numbers have sign , 1’s and 2’s complement.
1 1 1 1
*1 1 1 1
Carry- (10) 2 1
3 1 1 1 1
3 11 1 1
2 1 1 1 1
11 1 1
___________________________________________________________________________
15*15=225
11100001=1*2^7+1*2^6+1*2^5+0*2^4+0*2^3+0*2^2+0*2^1+1*2^0
128+64+32+0+0+0+0+1=225
The Main drawback of this manual multiplication of unsigned number is that more number of
register is needed to store the partial product as well as more cycle is needed for summation
operation.
The solution for this is the optimization algorithm which is also called as the accumulated addition
approach. The flow chart for this unsigned multiplication method is shown below:
Start
M = Multiplicand
Q= Multiplier
C,A=0
Count= n
No Yes
Is q(0)=1 C,A=A+M
Shift Right C, A ,Q
Count=Count-1
NO
Count=0
Yes
C A Q
Count=count-1
Count=4-1=3
0 0101 111 0q(0)
Step 1
_______________________________________________________________________________
Step=2
__________________________________________________________________________________
0 perform C, A=A+M
A+M=0010+1011=1101
Count=count-1=2-1=1
Step 3
__________________________________________________________________________________
perform C, A=A+M
A+M=0110+1011= 1 0001
0 1000 1111
Step=4
_________________________________________________________________________________
11*13=143
Signed Multiplication: (Booth’s Multiplication or Bit Pair Multiplication)
1. Signed multiplication is performed based on the bit pair operation
2. Bit pair operation are formulated based on the multiplier
3. To get initial bit pair there is a need of one assumption that q(-1) is always set to 0
q3 q2 q1 q0 q(-1)
00 0 SR(shift right)
10 -1 Subtraction and SR
11 0 SR
Question) Consider following Booth’s multiplier and identify the recorded Booth’s multiplier and
also identify how many alternative operations are required during the multiplication process.
Multiplier: q(-1)
101101101011 0
10 -1
11 0
01 +1
10 -1
01 +1
01 +1
10 -1
11 0
01 +1
10 -1______
Booth’s Multiplication:
Start
M = Multiplicand
Q= Multiplier
q(-1), A=0
Count= n
10 01
q(0) , q(-1) A=A+M
Count=Count-1
NO
Count=0
Yes
Q(7) q(-1)
0111 0
10 -1
11 0
11 0
01 +1
A Q q(-1)
_________________________________________________________
A=A-M
A=0000+0110=0110
0110 0111 0
Step 1
Count=count-1=3-1=2
0001 1001 1
Step 2
Count=count-1=2-1=1
0001 1001 1
Step 3
101 0110 0
Step 4
Final result in A and Q
A Q
Sign magnitude
( 0+2+4+0+16+0+64-128) = -42
Division
The bits of the dividend are examined from left to right, until the sets of bits examined represents a
number greater than or equal to the divisor. The divisor being able to divide the number until this
event occurs 0’s are placed in the quotient from left to right when the event occurs ,a 1 is placed in
the quotient and the divisor is subtracted from the partial dividend. The result is referred to as a
partial remainder.
SOLVE YOURSELF
b) 56/7=111000/111 ;111------
SOLVE YOURSELF
1. Restoring division
2. Non- Restoring division
Start
C,A =A-M
Yes
NO C=1 ? q(0)=0
q(0)=1
A=A+M
Count=Count-1
No Yes
Count=0
Stop
Question) Perform division of the following number using Restoring Method
Dividend(Q) = 17
Divisor(M)= 03
17/3 17= (10001)2 (Q) ; 3= (00011)2 (M) number of bits=5; Divisor should be (n+1) bits for
handling borrow .
Restoring Method :
1. Left shift
2. Subtraction
3. Carry control bits (using NOT gate)
Solution) Dividend(Q) = 17
Divisor(M)= 03
17/3 17= (10001)2 (Q) ; 3= (00011)2 (M) number of bits=5; Divisor should be (n+1) bits for
handling borrow.
C A Q(17 Dividend) :
C,A=A+M=11110+000011(restoring operation)
=(discard 1) 000001
Step 1
Step 2
0 00001 01001(invert of C)
Count=3-1=2
Step 3
0 00001 01001
=111111
Step 4
0 00010 10010
Count=0
NO Yes
q(0)=0 A is positive q(0)=1
Count=Count-1
No Yes A
Count=0
Yes
A=A+M A is negative
NO
End
M(divisor)=03= 0011 =(n+1) bits ; M= 00011 ; -M=11101 (2’s complement of M)
C A Q
Step 1
Step 2
C,A=11100+00011=11111
: count=3-1=2
Step 3
C,A=11111+00011=1 00010
: count= 2-1=1
Step 4
C,A=00100+11101=1 00001
: count= 1-1=0
a. To represent the above number with less memory space there is a need of a special format
called as floating point format.
b. The general form of floating point is: (+-) M*B + - e
+ - = sign ; M : Mantissa ; B: Base/ Radix ; e: exponent
To store any number into floating point format verify the number is in general format or not
Example 1 : 9780000000000000. * 10 0 – e (shift right ; exponent Will increase(positive))
M= 9780000000000000 ; B= 10 ; 9.78 * 10 + 13
Example 2 : 0.0000000000978 * 10 0
To store the floating point number in the main memory, there is a needof internal structure of the
floating point number. Floating point number consist of three parts:
1. Sign
2. Biased exponent
3. Mantissa
Sign bit is either positive(0) or negative(1)
Bias exponent is a equal to Actual exponent +Bias. Bias is a maximum possible positive
exponent.
Bias Exponent Range= -(2n-1) to (2n-1 -1) ; if n=6 ; Range is -32 to +31; if n=9 Range is -256 to +255
Mantissa floating point number is always represented in the form of normalized format. The general
form of normalization is : 1.bbbb…..; (1 before decimal point is by default ;and the value of b is 0/1)
Question) Consider the following number and represent it in 20 bit hypothetical floating point
format. + 101011 ; Check General Form: (+-)M * B+- e ; 101011. * 20 (check the
normalization(1.bbbb…))
1 6 13
Bias Exponent= Actual Exponent + Bias =5+(+31)= +36 (Range of Bias=26-1 - 1 =31)
Range of floating point numbers: IEEE standard floating point number. According to IEEE Standard
format 2 kind of floating point format are defined
__________________________ 32 _________________________________________
Mantissa: 1.00000000000000000000000
Question) The value of a float type variable is represented using the single precision 32 bit floating
point format IEEE 754 standard that uses 1 bit for sign 8 bit for biased exponent and 23 bits for
mantissa, a float type variable X is assigned the decimal value of -14.25 .The representation of X in
hexadecimal notation is:
___________________________________32bit__________________________________________
Biased Exponent (B.E)= Actual Exponent + Bias=3+127=130 ; (binary format of 130 is=(10000010)2
1 100|0001|0 110|0100|0000|0000|0000|0000
C1640000 (answer)