Number Representation

Tom Kelliher, CS 220

Sept. 26, 1997

Announcements

Midterm in one week.

Assignment

Problems 3.8, 3.10, and 3.13. For problem 3.13, replace fraction with non-integer.

Number Representation

Properties of conventional number systems:

  1. Positional.

  2. Weighted.

  3. Radix/Base.

  4. Most significant, least significant.

Unsigned value of a binary integer:

  1. n bit number.

  2. Bit numbering.

Base Conversions

Common bases: decimal, binary, octal, hexadecimal.

Binary to Decimal

Use the previous summation and do all math in decimal.

Example: convert binary 110101 to decimal.

(How well do you know your powers of 2?)

Decimal to Binary

Algorithm:

let dnum be the decimal number to convert;
index = 0;
bnum = 0;

while (dnum != 0)
{
   bnum[index] = dnum % 2;
   dnum = dnum / 2;
   index = index + 1;
}

Example: convert decimal 133 to binary.

Binary to Hex/Octal and Vice Versa

Form for octal & hexadecimal constants in C?

Conversion examples?

Fractions

  1. Fractional powers of 2.

  2. Converting a fractional binary number to decimal.

  3. Using the algorithm to convert a decimal integer to a binary integer as a starting point, develop an algorithm to convert a decimal fraction to a binary fraction.

  4. Examples.

Floating Point Numbers

  1. Scientific notation: mantissa and exponent.

  2. Normalization:
    1. Floating point mantissas are fractions.

    2. Normalized range:

    3. Why bother with normalizing?

    4. Gradual underflow and de-normalized numbers.

    5. The IEEE standard.

  3. Density of representable values on the number line.

  4. Quantization error.

  5. Precision and Accuracy.



Thomas P. Kelliher
Thu Sep 25 17:39:32 EDT 1997
Tom Kelliher