Floating-Point Representation Overview
You'll learn how computers represent real numbers by splitting them into three parts: sign, exponent, and significand.
The Core Idea
While integers are straightforward to represent in binary, real numbers (like 3.14159, 0.000002, or -1234567890.123) pose a challenge. Computers can't store infinite precision, so they use floating-point representation—a clever scheme that works like scientific notation.
Think of how we write very large or small numbers in science: 6.022 × 10²³ (Avogadro's number) or 9.109 × 10⁻³¹ (electron mass). Instead of writing out all those zeros, we separate the number into:
- A sign (positive or negative)
- A significand (the meaningful digits: 6.022 or 9.109)
- An exponent (the power of 10: 23 or -31)
How It Maps to Binary
Floating-point numbers in computers work the same way, but in binary:
- Sign bit: 1 bit indicating positive (0) or negative (1)
- Exponent field: Several bits storing the power of 2 (not 10)
- Significand (or mantissa) field: The actual significant digits in binary
For example, the decimal number -12.5 becomes:
- Sign: negative (1)
- Significand: 1.5625 in binary form
- Exponent: 3 (because 1.5625 × 2³ = 12.5)
These three fields are packed together into a fixed number of bits, allowing computers to represent an enormous range of values—from astronomically large to infinitesimally small—with finite hardware.
Key Takeaway: Floating-point representation uses three separate fields (sign, exponent, and significand) to efficiently encode real numbers in binary, similar to how scientific notation works in decimal.