Number Representation and Their Operations
Number Representation and Their Operations
Operations
Numbers can be represented in 3 formats:
i. Signed magnitude
ii. 1's complement
iii. 2's complement
• In all three formats, MSB=0 for +ve numbers & MSB=1 for -ve
numbers.
• In signed magnitude system, negative value is obtained by
changing the MSB from 0 to 1 of the corresponding positive value.
For ex, +5 is represented by 0101 & -5 is represented by 1101.
• In 1's complement system, negative values are obtained by
complementing each bit of the corresponding positive number.
For ex, -5 is obtained by complementing each bit in 0101 to yield
1010.
• In 2's complement system, the 2's complement of a number is
obtained by adding 1 to the 1's complement of that number. For
ex, -5 is obtained by complementing each bit in 0101 & then
adding 1 to yield 1011.
Addition and Subtraction of Signed
Magnitude Data
• We designate the magnitude of the two numbers by A and B.
• When the signed numbers are added or subtracted, we find that there
are eight different conditions to consider, depending on the sign of the
numbers and the operation performed.
• These conditions are listed in the first column of Table.
• The algorithms for addition and subtraction are derived from the table.
Addition (subtraction) algorithm
• (8) + (- 3) = 5
• (- 8) + (- 3) = - 11
• (8) - (- 3) = 11
• (- 8) - (- 3) = - 5
Addition and subtraction with Signed- 2's
Complement Data
Hardware for signed-2's Complement
addition and subtraction
Hardware for signed-2's Complement
addition and subtraction
Example: (-3)
First find the binary value of (+ 3) then find the 2's complement.
+3 = 0011
2's complement =1100 +1= 1101
-3 =1101
Multiplication Algorithm in Signed Magnitude
2. Flip Flop:
To store sign bit of registers we require three flip flops (A sign,
B sign and Q sign).
Flip flop E is used to store carry bit generated during partial
product addition.
3. Complement and Parallel adder:
This hardware unit is used in calculating partial product i.e,
perform addition required.
Flowchart of Multiplication:
1. Initially multiplicand is stored in B register and multiplier is
stored in Q register.
2. Sign of registers B (Bs) and Q (Qs) are compared
using XOR functionality (i.e., if both the signs are alike, output
of XOR operation is 0 unless 1) and output stored in As (sign of
A register).Note: Initially 0 is assigned to register A and E flip
flop. Sequence counter is initialized with value n, n is the
number of bits in the Multiplier.
3. Now least significant bit of multiplier is checked. If it is 1 add
the content of register A with Multiplicand (register B) and
result is assigned in A register with carry bit in flip flop E.
Content of E A Q is shifted to right by one position, i.e., content
of E is shifted to most significant bit (MSB) of A and least
significant bit of A is shifted to most significant bit of Q.
4. If Qn = 0, only shift right operation on content of E A Q is
performed in a similar fashion.
5. Content of Sequence counter is decremented by 1.
6. Check the content of Sequence counter (SC), if it is 0, end the
process and the final product is present in register A and Q, else
repeat the process.
Example:
Multiplicand – 10111
Multiplier - 10011
Booth’s Algorithm of Multiplication