Professional Documents
Culture Documents
Figure 2.3
Expanded Structure of IAS
Computer on page 22 (William
Stallings Computer
Organization and
Architecture Designing
for Performance
(8th edition).pdf)
INSIDE THE ALU
INTEGER REPRESENTRATION
WHAT IS INTEGER REPRESENTATION
To fully understand how binary numbers are processed we must
have an understanding of how integers are handle by the
computer. For instance:
How are negative numbers represented?
How are floating point numbers represented?
Processing how we add, subtract, divide and multiply?
INTEGER REPRESENTATION
In the binary number system, arbitrary numbers can be
represented with just the digits zero and one, the minus sign,
and the period, or radix point. For purposes of computer storage
and processing, however, we do not have the benefit of minus
signs and periods. Only binary digits (0 and 1) may be used to
represent numbers. If we are limited to nonnegative integers,
the representation is straightforward.
SUB-TOPICS
Sign-Magnitude Representation
Twos Complement Representation
Converting between Different Bit Lengths
Fixed-Point Representation
Sign-Magnitude Representation
There are several alternative conventions used to represent
negative as well as positive integers, all of which involve
treating the most significant (leftmost) bit in the word as a sign
bit ( ). The general rule is that, if the sign bit is 0, the number is
positive; if the sign bit is 1, the number is negative. To simplify,
positive numbers starts with 0 and negative numbers starts with
1. The simplest form of representation that employs a sign bit is
the sign-magnitude representation. In an n-bit word, the
rightmost bits hold the magnitude of the integer.
Ones Complement
What is a Complement?
It is the opposite of something.
Because computers do not like to subtract, this method finds the
complement of a positive number and then addition can take
place.
First method
Steps:
1.Convert number to binary
2.Swap all the bits
3.Check answer by adding 127
.(SHOW EXAMPLE!!)
Second method
Given a number x which can be expressed as an n-bit binary
number, its negative value can be obtained in Ones
Complement representation using: -x= 2n-x-1
Example:
With an 8-bit number 00001100, its negative value, expressed in
Ones Complement, is obtained as follows:
(SHOW SOLUTION!!)
(APPLY THE FIRST METHOD WITH THE SAME GIVEN)
Twos complement
The only difference between two processes is that the left most bit
is -128 rather than -127.
First method
The process for Twos complement is exactly the same as ones
complement, however you are then required to add 1 to the results
Steps:
1.Convert number to binary
2.Swap all the bits
3.Add 1 to the result
(SHOW EXAMPLE)
(Show the use of value box)
Second method
Given a number x which can be expressed as an n-bit binary
number, its negative number can be obtained in Twos
Complement representation using: -x= 2n-x
Example: With an 8-bit number 00001100, its negative value in
Twos Complement is thus:
(SHOW SOLUTION!!)
(APPLY STEP 3 OF FIRST METHOD)
(ANSWER IS NEGATIVE)
Decimal-to-Binary Conversion
Method 1: Sum-of-Weights Method
Method 2: Repeated Division-by-2 Method (for whole numbers)
Repeated Multiplication-by-2 Method (for fractions)
Sum-of-Weights Method
Determine the set of binary weights whose sum is equal to the
decimal number.
9= 8 + 1 = 23 +20 = 1001
18= 16 + 2 = 24 +21 = 10010
58= 32 + 16 + 8 + 2 = 25 +24 +23 +21 = 111010
0.625= 0.5 + 0.125 = 2-1 +2-3 = 0.101
Fixed-Point Representation
This method assumes the decimal point is in fixed position.
Example: 10011101=10011.101
Therefore
16 + 2 + 1 = 19
0.5 + 0.125 = 0.625
So 10011.101 = 19.625
Representation of Fraction
Fractional number are numbers between 0 and 1.
Example: 23.714 = 01101.1001
Problems are:
You fix the number that you can represent. You are limited to amount of
numbers that you can actually represent.