Saturday, 27 October 2012

ARITHMETICS FOR COMPUTER: INTEGER REPRESENTIVE

  • 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.

An 8-bit word can represent the numbers from 0 to 255, including
                                                                 00000000   =      0
                                                                 00000001   =      1
                                                                 00101001   =    41
                                                                10000000    =  128
                                                                11111111    =  255


Sign-Magnitude Representation


  • treat the most significant (leftmost) bit in the word as a sign bit. If the sign bit is 0, the number is positive; if the sign bit is 1, the number is negative.
  • 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.
  • The general case can be expressed as follows:

  • there are two representations of 0:

Twos Complement Representation


  • uses the most significant bit as a sign bit, making it easy to test whether an integer is positive or negative.

  • It differs from the use of the sign-magnitude representation in the way that the other bits are interpreted.
Characteristics of Twos Complement Representation and Arithmetic
  • The number zero is identified as positive and therefore has a 0 sign bit and a magnitude of all 0s.
  • the range of positive integers that may be represented is from 0 (all of the magnitude bits are 0) through (all of the magnitude bits are 1). Any larger number would require more bits.



  • Equation above defines the twos complement representation for both positive and negative numbers.






Converting between Different Bit Lengths


  • It is sometimes desirable to take an n-bit integer and store it in m bits, where m > n .
  • In sign-magnitude notation, this is easily accomplished: simply move the sign bit to the new leftmost position and fill in with zeros.

  This procedure will not work for twos complement negative integers. Using the
                   same example,


  • Instead, the rule for twos complement integers is to move the sign bit to the new leftmost position and fill in with copies of the sign bit. 
  • For positive numbers, fill in with zeros, and 
  • for negative numbers, fill in with ones. 
  • This is called sign extension.



Fixed-Point Representation


  • we mention that the representations discussed in this section are sometimes referred to as fixed point.This is because the radix point (binary point) is fixed and assumed to be to the right of the rightmost digit.









No comments:

Post a Comment