Data Representation
Data Representation
Computer Arithmetic
Computer arithmetic is commonly performed
on two very different types of numbers:
• Integer
• Floating point
ALU Inputs and Outputs
Integer Representation
Sign-Magnitude Representation
The simplest form of representation that
employs a sign bit is the sign-magnitude
representation. In an n-bit word, the rightmost
n - 1 bits hold the magnitude of the integer.
Drawbacks to Sign-Magnitude
Representation
• Addition and subtraction require a
consideration of both the signs of the numbers
and their relative magnitudes to carry out the
required operation.
• There are two representations of 0.
Solution: Twos Complement
Representation
Representation of Positive and
Negative Numbers
• If A is positive, then the sign bit, an-1, is zero. If A
is Negative, then the sign bit, an-1, will be One.
The remaining bits represent the magnitude of the
number in the same fashion as for sign
magnitude:
Number Range
• We can see that the range of positive integers
that may be represented is from 0 (all of the
magnitude bits are 0) through 2n-1 - 1 (all of
the magnitude bits are 1).
• The range of negative integers that can be
represented is from -1 to -2n-1 .
Number Range
Value Box Representation
Range Extension
• It is sometimes desirable to take an n-bit
integer and store it in m bits, where m > n.
This expansion of bit length is referred to as
range extension, because the range of
numbers that can be expressed is extended by
increasing the bit length.
Range Expansion in Sign-Magnitude
Notation
• In sign-magnitude notation, this is easily
accomplished: simply move the sign bit to the
new leftmost position and fill in with zeros.
Range Expansion in Twos-
Complement Notation
This procedure will not work for twos complement
negative integers.