Floating-point numbers are often described as “real numbers,” but in reality they are subsets of rational numbers.
Theoretical Representation
We can understand rational numbers as scientific notation with base 2:
However, with the above representation we may have multiple representations for the same number. For example,
Afterward, the first bit become redundant as it is always
IEEE Float
In memory, an IEEE floating point number consists one sign bit,
f32
:, f64
:,
We can use bit operations to isolate sign bit, exponent bits, or mantissa bits.