2. Table of Contents
Addition and subtraction of signed numbers
Design of fast adders
Multiplication of positive numbers
Signed operand multiplication,
Fast multiplication- Bit pair recoding of Multipliers,
Carry Save Addition of summands
Integer division – Restoring Division and Non
Restoring Division
Floating point numbers and operations
3. Integer Representation
• Only have 0 & 1 to represent everything
• Positive numbers stored in binary
– e.g. 41=00101001
• No minus sign
• No period
• Sign-Magnitude
• One's Complement
• Two’s compliment
5. • Negating a two's complement number: invert all bits and
add 1
– remember: “negate” and “invert” are quite different!
• Converting n bit numbers into numbers with more than n
bits:
– MIPS 16 bit immediate gets converted to 32 bits for arithmetic
– copy the most significant bit (the sign bit) into the other bits
0010 -> 0000 0010
1010 -> 1111 1010
– "sign extension" (lbu vs. lb)
Two's Complement Operations
6. Signed and unsigned additions
• Unsigned addition
in 4-bit arithmetic
( carry) 11_
1011
+ 0011
1110
• 11 + 3 = 14
(8 + 4 + 2)
• Signed addition in
4-bit arithmetic
( carry) 11_
1011
+ 0011
1110
• -5 + 3 = -2
7. Signed and unsigned additions
• Same rules apply even though bit strings
represent different values
• Sole difference is overflow handling
8. Sign-Magnitude
• Left most bit is sign bit
• 0 means positive
• 1 means negative
• +18 = 00010010
• -18 = 10010010
• Problems
– Need to consider both sign and magnitude in
arithmetic
– Two representations of zero (+0 and -0)
10. Conversion Between Lengths
• Positive number pack with leading zeros
• +18 = 00010010
• +18 = 00000000 00010010
• Negative numbers pack with leading ones
• -18 = 10010010
• -18 = 11111111 10010010
• i.e. pack with MSB (sign bit)
11. Addition and Subtraction
• Normal binary addition
• Monitor sign bit for overflow
• Take twos compliment of substahend and add
to minuend
– i.e. a - b = a + (-b)
• So we only need addition and complement
circuits