FLOAT (floating point)
A number type that stores decimals in binary as an approximation. It's fast and small, but some decimals, like 0.1, aren't exact.
Example
With FLOAT, 0.1 + 0.2 gives 0.30000000000000004. Fine for a temperature (23.5 °C), not for money.
Test yourself: FLOAT (floating point)
How numbers are stored
A float works like scientific notation, but in base ___.
In base 10, 1,500 is 1.5 × 10³. A float stores something like 1.375 × 2⁻³ = 0.171875.
How numbers are stored
What does a float give up in exchange for its huge range?
A 32-bit float stores 16,777,216 fine, but 16,777,217 doesn't fit exactly and is rounded to its neighbor.
How numbers are stored
In a float, what does 0 / 0 give?
Any number times 0 gives 0, so 0 / 0 has no single result: it's NaN. 1 / 0, on the other hand, gives infinity.
0/3
▶ Play