CMPT 295

Have you heard of that new band “1023 Megabytes”?

They’re pretty good, but they don’t have a gig just yet. 😭

Last Lecture

We interpret the bit vector (expressed in IEEE floating point encoding) stored in memory using this equation.

Today’s Menu

IEEE Floating Point Representation Three “kinds” of values

We interpret the bit vector (expressed in IEEE floating point encoding) stored in memory using this equation:

V=(1)sM2E V = (-1)^{s} M 2^{E}

Bit breakdown–exp and frac interpreted as unsigned:

IEEE floating point representation - normalized

Numerical Form: V=(1)sM2EV = (–1)^{s} M 2^{E}

Bit breakdown:

Why is E biased?

Using single precision as an example (s = 1 bit, exp = 8 bits, frac = 23 bits):

Review: Scientific Notation and normalization

Syntax of normalized notation:

Name Notation
Sign +/-
Significant d0,d1,d2,d3d_{0}, d_{-1}, d_{-2}, d_{-3}dnd_{-n}
Base b
Exponent exp^{\text{exp}}

Let’s try normalizing these fractional binary numbers!

  1. 101011010.1012101011010.101_{2}
  2. 0.00000000110120.000000001101_{2}
  3. 11000000111001211000000111001_{2}

IEEE floating point representation

Why adding 1 to frac (or subtracting 1 from M)?

Why adding 1 to frac (or subtracting 1 from M)?

Implying this bit has the following effects:

We get the leading bit for free!

  1. We save 1 bit when we convert (represent) a fractional decimal number into a bit pattern using IEEE 754 floating point representation
  2. We have to add this 1 bit back when we convert from a bit pattern (IEEE 754 floating point representation) back to a fractional decimal

Example: V=(1)sM2E=1.01011010101×28V = (–1)^{s} M 2^{E} = 1.01011010101 \times 2^{8}

M = 1. 01011010101 => M = 1 + frac

This bit is implied hence not stored in the bit pattern produced by the IEEE 754 floating point representation, and what we store in the frac part of the IEEE 754 bit pattern is 01011010101

IEEE floating point representation (single precision)

Numerical Form: V=(1)sM2EV = (–1)^{s} M 2^{E}

Value Notes
1  
10000111 k=8 bits, interpreted as unsigned
01011010101000000000000 n=23 bits, interpreted as unsigned

Little endian memory layout:

Address M[]
size-1  
0x0003 11000011
0x0002 10101101
0x0001 01010000
0x0000 00000000

Let’s give it a go!

Numerical form: V=(1)sM2EV = (-1)^{s} M 2^{E}

single precision

Value Notes
0  
10001100 k=8 bits, interpreted as unsigned
11011011011000000000000 n=23 bits, interpreted as unsigned

Little endian memory map:

Address M[]
size-1  
0x0003 01000110
0x0002 01101101
0x0001 10110000
0x0000 00000000

IEEE floating point representation (single precision)

How would 47.21875 be encoded as IEEE floating point number?

  1. Convert 47.28 to binary (using the positional notation R2B(X)) =>
    • 47=101111247 = 101111_{2}
    • .21875=.001112.21875 = .00111_{2}
  2. Normalize binary number: 101111.00111 => 1.01111001112×251.0111100111_{2} \times 2^{5}
    • V=(1)sM2EV = (–1)^{s} M 2^{E}
  3. Determine …
    • s = 0
    • E = exp – bias where bias=2k11=271=1281=127\text{bias} = 2^{k-1} – 1 = 2^{7} – 1 = 128 – 1 = 127
    • exp = E + bias = 5 + 127 = 132 => U2B(132) => 10000100
    • M = 1 + frac -> frac = M - 1 => 1.011110011121=.011110011121.0111100111_{2} - 1 = .0111100111_{2}
  4. 32 bits organized in s|exp|frac: [0|10000100|01111001110000000000000}
  5. 0x423CE000

IEEE floating point representation (single precision)

How would 12345.75 be encoded as IEEE floating point number?

V=(1)sM2E V = (-1)^{s} M 2^{E}

  1. Convert 12345.75 to binary
    • 12345 => ____ .75 => ____
  2. Normalize binary number:
  3. Determine …
    • s = ____
    • E = exp – bias where bias=2k11=271=1281=127\text{bias} = 2^{k-1} – 1 = 2^{7} – 1 = 128 – 1 = 127
    • exp = E + bias = ____
    • M = 1 + frac -> frac = M - 1
  4. [_|________|_______________________]
  5. Express in hex:

Summary

Next Lecture