Number Representation

Tom Kelliher, CS 220

Sept. 29, 1997

Announcements

Review on Wednesday.

Assignment

Read Chapter 4.

Number Representation Selection

Numerous ways of representing a value. Selection criteria:

  1. Ease of implementing: addition, negation (subtraction), comparison.

  2. Symmetry.

  3. Speed.

  4. Hardware requirements.

One of the ``holy wars'' in architecture:

  1. Memory is byte addressable.

  2. A word is multiple bytes/bits.

  3. How are the bytes/bits numbered?

  4. Little endian.

  5. Big endian.

Integer Representations

Bit numbering:

For examples, assume b = 8.

Unsigned

Unsigned value of an binary integer:

Maximum, minimum values and representations?

Sign-and-Magnitude Representation

Msb is the sign bit:

  1. Has no weight.

  2. If 0, the number is ``positive.''

  3. If 1, the number is ``negative.''

  4. Value:

  5. Problems:
    1. Multiple representations of 0.

    2. Hard to build good adders.

  6. Minimum, maximum values and representations?

  7. Symmetric range.

  8. Sign extension. Why is this important?

1's-Complement Representation

Msb is the sign bit:

  1. Has negative weight: .

  2. If 0, the number is ``positive.''

  3. If 1, the number is ``negative.''

  4. One's complement:

  5. Value:

    How did we get the weight for ?

  6. Problems:
    1. Multiple representations of 0.

    2. Wrap-around carrys.

  7. Minimum, maximum values and representations?

  8. Symmetric range.

  9. Sign extension.

2's-Complement Representation

Msb is the sign bit:

  1. Has negative weight: .

  2. If 0, the number is ``positive.''

  3. If 1, the number is ``negative.''

  4. Two's complement:

    One's complement plus one.

  5. Value:

  6. Problems:
    1. Asymmetric range.

  7. Minimum, maximum values and representations?

  8. Sign extension. Why does this work?

Bias Representation

  1. Add a bias to a value to get the representation.

  2. Bias 127: add 127 to value.

  3. value:

    where B is the bias.

  4. Minimum, maximum values and representations?

  5. Used for exponent representation in floating point.

Example Conversions

Represent each of the following in sign-magnitude, one's complement, two's complement, and bias 127 form: 1, -1, 127, -127, 128, -128, 45, -45.

Character Representation

  1. ASCII.

  2. One character per byte.

  3. Packed formats --- importance of shifts.



Thomas P. Kelliher
Mon Sep 29 08:09:06 EDT 1997
Tom Kelliher