Computers are bad at math. If you go into your friendly local Python terminal or JavaScript console, and type “0.1 + 0.1 + 0.1”, it will produce a number that is almost, but not quite 0.3. When you try to write programs that do math, things like this often happen. You may have heard that it’s because the number is “floating point.”
There’s a lot of superstition and folklore around floating-point numbers in computer science, plausibly due to occult-sounding terms like “mantissa” and “significand.” “Floating-point math is imprecise,” people will say. But the “floating-point” part gets way too much emphasis. “Math is too precise” is a better way to put it. The poor floating-point number is just chronically misunderstood.
Tagged as computers, math, low-effort titles.