Briefle words · Code & architecture
Decimal type
A number type that does exact base-10 arithmetic, used when fractions of money must be calculated precisely.
Say it to an AI
Python function that totals a cart with tax, keeping money as integer minor units (cents) end to end. Compute tax with the Decimal type and an explicit rounding mode (ROUND_HALF_UP) to whole cents; only convert to dollars when formatting. No floats anywhere in the money path.
How an expert would brief the stronger version of “Cart total”.
See it
Try it as a puzzle →A grocery delivery team prototypes the checkout total calculation in a notebook.
Why: B multiplies by Decimal("0.0825") and rounds with quantize(1, ROUND_HALF_UP); A multiplies by the float 0.0825 and never rounds on purpose.
Related words
Room 5 · APIs & data
Learn “Decimal type” in a five-minute lesson