CS 208 w20 lecture 6 outline

1 Poll

What is the base 10 equivalent of the 6-bit two's complement fixed-point number 0b101.110?

2 IEEE floating point in 6 bits

\(V = (-1)^s \times M \times 2^E\)

ieee-6-bit.png

  • s encodes \(s\)
  • exp encodes \(E\) in biased form
    • normally, \(E\) = exp \(- Bias\) where the \(k\) bits of exp are treated as an unsigned integer and \(Bias = 2^{k-1} - 1\)
  • frac is the binary fraction \(0.f_{n-1}\cdots f_1f_0\), and the significand is \(M = 1 + f\)

2.1 Example

  • Take the same six bits from before, 0b1 011 10, what value do they represent under this scheme?
    • s is 1, so value is negative
    • exp is 3, so \(E = 3 - 3 = 0\)
    • frac is 0.5, so \(M = 1 + 0.5 = 1.5\)
    • V = -1.5 × 20 = -1.5

2.2 Why the biased form for exponents?

  • we want to represent very small and very large numbers, so we need the exponent to be signed
    • this suggests encoding exp as a two's complement integer
  • we want floating-point operations to be fast in hardware
    • easier to compare floats if more 1s in exp means bigger number
  • clever trick: store exp as unsigned with implicit bias
    • in fact, by putting exp in between s and frac, the same hardware can do two's complement comparisons and floating-point comparisons

2.3 Denormalized values

  • When exp is 0, the representation switches from normalized to denormalized form
  • \(E = 1 - Bias\)
  • \(M = f\)

3 Group activity exploring representing real numbers with bits

  • Why go with IEEE instead of fixed point, what's the trade-off

4 Real IEEE

ieee-precisions.png

ieee-distribution.png

4.1 Special cases

fp-cases.png

5 Useful simulation

6 Arithmetic

  • IEEE standard specifies four rounding modes
    • typically round-to-even, helps avoid statistical bias in practice by distributing rounding between rounding up and rounding down
  • In general, perform exact computation and then round to something representable with available bits
    • can underflow if closest representable value is 0
    • can overflow if \(E\) is too big to fit in exp (result is \(\pm\infty\))
    • rounding breaks associtivity

7 Annoucements

  • Lab 1 out
  • Submit lecture feedback
  • Wednesday guest lecture from job candidate and going over quiz