Concepts: Numbers and maths¶
Short essays on the ideas behind numbers in Python. Read these once and keep coming back to them when a calculation surprises you or you're deciding how to store a quantity.
Essays in this section¶
- How floating point works — what a
floatactually is: IEEE 754 double precision, why a tidy decimal like0.1can't be stored exactly, where the 53 bits of precision go, and what all of that means for the code you write. - Choosing a numeric type — a first-principles guide to picking between
int,float,Decimal, andFraction: exactness versus speed and range, and the kinds of quantity each one is built for.