Skip to content
BIASED

Floating-point numbers

Block 1 of 6~2 min

Why not fixed point

Integers are exact on a short, evenly spaced range: 32 bits hold every integer from about −2.1×109-2.1\times 10^9 to 2.1×1092.1\times 10^9, spaced 1 apart. Science needs 10−3010^{-30} and 103010^{30} with a few significant digits, and fractions such as 0.10.1.

Notation. x=(−1)s⋅m⋅2ex=(-1)^s\cdot m\cdot 2^e with sign ss, significand mm, exponent ee. Stored fields: unsigned exponent EE, fraction ff, bias, precision pp (24 single, 53 double). fl(x)\mathrm{fl}(x) is xx rounded to a representable value; ulp⁡(x)\operatorname{ulp}(x) the local gap; ε=21−p\varepsilon=2^{1-p} machine epsilon; u=ε/2=2−pu=\varepsilon/2=2^{-p} unit roundoff.

Baseline: fixed point. Q16.16 reads a 32-bit two’s-complement integer qq as q/216q/2^{16}. Spacing 2−16≈1.5×10−52^{-16}\approx 1.5\times 10^{-5} everywhere; 0.10.1 becomes 6554/65536≈0.1000066554/65536\approx 0.100006 (0.006% error). Absolute error is fixed, so relative error explodes for tiny values — 10−510^{-5} is stored 53% too large, and anything below 2−172^{-17} becomes 0. The range stops near 32,768, so a product of two moderate numbers overflows. Fixed point survives when the range is known (DSP, quantized nets). For general work the scale must travel with the number.

Answers are saved on the server and tied to this browser until you sign in.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • Decode FP32 bit fieldsoptional

    Split 32 bits into sign/exponent/mantissa; rebuild ±1.f×2^e and match numpy.float32.

    ~20 min · easier on a computer · The matching course topic has been read.

    Self-check in the notebook — not part of mastery or the certificate.