0% found this document useful (0 votes)
9 views24 pages

Unit 2 - 2.2 - Integer Representation

Uploaded by

terepapakamaal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views24 pages

Unit 2 - 2.2 - Integer Representation

Uploaded by

terepapakamaal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Unit-2_2

COMPUTER ORGANIZATION AND ARCHITECTURE

Topic: Integer Representation & Binary Arithmetic

1
Outline

• Integer Representation
• Binary Addition
• Binary Subtraction
• Binary Multiplication
• Booth’s Algorithm

2
Integer Representation
• Integer Representation refers to how the computer stores or represents a number in memory.
• The computer represents numbers in binary (1's and 0’s).
• As computer has a limited amount of space that can be used for each number or variable.
• This directly impacts the size, or range, of the number that can be represented.
• Computers uses a fixed number of bits to represent an integer.
• The commonly-used bit-lengths for integers are 8-bit, 16-bit, 32-bit or 64-bit.
• Besides bit-lengths, there are two representation schemes for integers:
1. Unsigned Integers: can represent zero and positive integers
2. Signed Integers: can represent zero, positive and negative integers

• Three representation schemes had been proposed for signed integers:


1.Sign-Magnitude representation
2.1's Complement representation
3.2's Complement representation

3
Integer

Signed
•Sign and Magnitude
•1’s Complement
•2’s Complement

Unsigned
4
Unsigned Integers

• Unsigned integers can represent zero and positive integers, but not negative integers. An n-bit
unsigned integer can represent integers from 0 to (2^n)-1

n= number of bits Minimum Maximum


8 0 (2^8)-1 (=255)
16 0 (2^16)-1 (=65,535)

32 0 (2^32)-1 (=4,294,967,295) (9+ digits)

64 0 (2^64)-1 (=18,446,744,073,709,551,615) (19+ digits)

5
Signed Integers- Sign Magnitude Representation

• The most-significant bit (msb) is the sign bit,


• 0 representing positive integer
• 1 representing negative integer.
• The remaining n-1 bits represents the magnitude (absolute
value) of the integer.

6
0 and -0 ?

• This is not possible in number


system.
• so this is drawback of sign and
magnitude representation method.
• Therefore we use 2’s complement
method to represent signed number

7
In sign magnitude representations, there are two different representations for 0.

8
1’s Complement Representation

9
Since the magnitude of both numbers is the same, the first 7 bits in the representation are the same for
both numbers. For +34, the MSB is 0, and for -34, the MSB or sign bit is 1

10
11
Binary Addition & Subtraction

• Addition proceeds as if the two numbers were unsigned integers.


• If the result of the operation is positive, we get a positive number in twos complement form,
which is the same as in unsigned-integer form.
• If the result of the operation is negative, we get a negative number in twos complement form.
• in some instances, there is a carry bit beyond the end of the word (indicated by shading), which is
ignored

12
Overflow

• On any addition, the result may be larger than can be held in the word size being used.
• This condition is called overflow. When overflow occurs, the ALU must signal this fact so that
no attempt is made to use the result.
• To detect overflow, the following rule is observed:
• OVERFLOW RULE: If two numbers are added, and they are both positive or both negative,
then overflow occurs if and only if the result has the opposite sign.

13
Hardware for Addition and Subtraction

14
Note that overflow can occur whether or not there is a carry.

15
SUBTRACTION RULE: To subtract one number (subtrahend) from another (minuend), take the twos
complement (negation) of the subtrahend and add it to the minuend

16
Multiplication
• Complex
• Work out partial product for each digit
• Take care with place value (column)
• Add partial products

17
Multiplication Example
1011 Multiplicand (11 dec)
x 1101 Multiplier (13 dec)
1011 Partial products
0000 Note: if multiplier bit is 1 copy
1011 multiplicand (place value)
1011 otherwise zero
10001111 Product (143 dec)
Note: need double length result

18
Unsigned Binary Multiplication

19
Flowchart for Unsigned Binary Multiplication

20
Multiplying Negative Numbers

• This does not work!


• Solution 1
– Convert to positive if required
– Multiply as above
– If signs were different, negate answer
• Solution 2
– Booth’s algorithm

21
Booth’s Algorithm

22
Example of Booth’s Algorithm

23
THANK YOU

24

Vishwakarma Institute of Technology, Pune

You might also like