DATA REPRESENTATION
ARITHMETIC & LOGIC UNIT
 Does the calculations
 Everything else in the computer is there to
service this unit
 Handles integers
 May handle floating point numbers
 May be separate FPU
ALU INPUTS AND OUTPUTS
INTEGER REPRESENTATION
 Only have binary digits (0 & 1) to represent
numbers.
 Positive numbers stored in binary
 e.g. 41=00101001
 Sign-Magnitude
 Two’s compliment
An 8 -bit word can represent the numbers from
0 to 255,including
00000000 = 0
00000001 = 1
00101001 = 41
10000000 = 128
11111111 = 255
If an n-bit sequence of binary digits an-1an-2…a1a0 is
interpreted as an unsigned integer A, its value is
A= i
n
i
i
a



1
0
2
SIGN-MAGNITUDE
 Left most bit is sign bit
 0 means positive
 1 means negative
 If there are n bits, then rightmost n-1 bits hold the magnitude of
the integer.
 +18 = 00010010
 -18 = 10010010
 Problems
 Need to consider both sign and magnitude in
arithmetic
 Two representations of zero (+0 and -0)
(e.g) +010 =00000000
-010 =10000000
CHARACTERISTICS OF TWOS COMPLEMENT
REPRESENTATION AND ARITHMETIC
BENEFITS
 One representation of zero
 Arithmetic works easily
 Negating is fairly easy
 3 = 00000011
 Boolean complement gives 11111100
 Add 1 to LSB gives 11111101
VALUE BOX FOR CONVERSION BETWEEN
TWOS COMPLEMENT BINARY AND DECIMAL
SOLUTION
Move the sign bit to the new leftmost position and fill in with
copies of the sign bit.(Sign Extension)
-18 = 11101110(twos complement,8 bits)
-18 = 1111111111101110(twos complement,16 bits)
NEGATION
Rules:
1) Take the Boolean complement of each bit of the
integer.(including the sign bit)
2) Treating the result as an unsigned binary integer , add
1.
Eg) +18 = 00010010
bitwise complement = 11101101
1 +
11101110 = -18
NEGATION SPECIAL CASE 1
 0 = 00000000
 Bitwise not 11111111
 Add 1 to LSB +1
 Result 1 00000000
 Overflow is ignored, so:
 - 0 = 0
NEGATION SPECIAL CASE 2
 -128 = 10000000
 bitwise not 01111111
 Add 1 to LSB +1
 Result 10000000
 So:
 -(-128) = -128

Data Representation.pptx

  • 1.
  • 2.
    ARITHMETIC & LOGICUNIT  Does the calculations  Everything else in the computer is there to service this unit  Handles integers  May handle floating point numbers  May be separate FPU
  • 3.
  • 4.
    INTEGER REPRESENTATION  Onlyhave binary digits (0 & 1) to represent numbers.  Positive numbers stored in binary  e.g. 41=00101001  Sign-Magnitude  Two’s compliment
  • 5.
    An 8 -bitword can represent the numbers from 0 to 255,including 00000000 = 0 00000001 = 1 00101001 = 41 10000000 = 128 11111111 = 255 If an n-bit sequence of binary digits an-1an-2…a1a0 is interpreted as an unsigned integer A, its value is A= i n i i a    1 0 2
  • 6.
    SIGN-MAGNITUDE  Left mostbit is sign bit  0 means positive  1 means negative  If there are n bits, then rightmost n-1 bits hold the magnitude of the integer.  +18 = 00010010  -18 = 10010010
  • 7.
     Problems  Needto consider both sign and magnitude in arithmetic  Two representations of zero (+0 and -0) (e.g) +010 =00000000 -010 =10000000
  • 8.
    CHARACTERISTICS OF TWOSCOMPLEMENT REPRESENTATION AND ARITHMETIC
  • 9.
    BENEFITS  One representationof zero  Arithmetic works easily  Negating is fairly easy  3 = 00000011  Boolean complement gives 11111100  Add 1 to LSB gives 11111101
  • 10.
    VALUE BOX FORCONVERSION BETWEEN TWOS COMPLEMENT BINARY AND DECIMAL
  • 12.
    SOLUTION Move the signbit to the new leftmost position and fill in with copies of the sign bit.(Sign Extension) -18 = 11101110(twos complement,8 bits) -18 = 1111111111101110(twos complement,16 bits)
  • 13.
    NEGATION Rules: 1) Take theBoolean complement of each bit of the integer.(including the sign bit) 2) Treating the result as an unsigned binary integer , add 1. Eg) +18 = 00010010 bitwise complement = 11101101 1 + 11101110 = -18
  • 14.
    NEGATION SPECIAL CASE1  0 = 00000000  Bitwise not 11111111  Add 1 to LSB +1  Result 1 00000000  Overflow is ignored, so:  - 0 = 0
  • 15.
    NEGATION SPECIAL CASE2  -128 = 10000000  bitwise not 01111111  Add 1 to LSB +1  Result 10000000  So:  -(-128) = -128