Floating point numbers: representation of non-integrl numbers use normalized format to achieve better readability

binary number format $\pm 1.xxx \times 2 ^ {yyy}$

  • $xxx$: fraction
  • $yyy$: exponent

IEEE floating point

$x = (-1)^s \cdot (1 + \text{Fraction}) \cdot 2^{(\text{exponent} - \text{bias})}$

when calculating the exponent/fraction, treat them as unsigned integer!

  • sign + exponent + fraction =
    • 1 + 8 + 7 (bfloat16)
    • 1 + 8 + 23 (single)
    • 1 + 11 + 32 (double)
  • c.f. exponent = 0 and (11…11) is not used!: reserverd
    • exponent = 0: hidden bit in he fraction is 0 (no add 1 in fraction)
    • fraction = 0: always zero!
    • exponent = (11..11), fraction = 0: $\pm \infty$
    • exponent = (11..11), fraction $\neq$ 0: NaN
  • bias equals: makes positive range 1 bigger!
    • 2**(8-1) - 1 = 127 (signle, brain)
    • 2**(11-1) - 1 = 1023 (double)

Floating point number arithmetics

  • Addition (how we do this)
    • align floating points (shift the number with smaller exponent)
    • add signficands
    • normalize result & check over/underflow
    • round & renormalize the number
  • Muliplication (how we do this)
    • add exponents
    • multiply significnas
    • normalize & check for over/underflow
    • round and renormalize if necessary
    • determine the sign of result from signs of operand

FP Adder Hardware

FP Multiplier Hardware

usually takes several cycles

MIPS FP arithmentic support

  • By cprocessor 1
  • FP registers
    • 32 single-precision $$f0, \cdots $f31$
    • paired 2 registers for 64 bit double-precision