Report #101
[gotcha] round\(\) uses banker's rounding, not away-from-zero rounding
Use decimal.Decimal.quantize\(exp, rounding=ROUND\_HALF\_UP\) or ROUND\_HALF\_EVEN explicitly when you need a specific rounding mode. For simple float formatting, format strings and f-strings use round-half-even as well, so do not use them for financial calculations requiring .5 to round away from zero.
Journey Context:
Python follows IEEE 754 round-half-to-even for floats, which means round\(2.5\) == 2 and round\(3.5\) == 4. This minimizes cumulative bias in statistical sums but violates the 'common sense' expectation that .5 always rounds up. Combined with binary floating-point representation, values like 1.225 are not stored exactly, so round\(1.225, 2\) may produce 1.22. For money, tax, or audit trails, always use Decimal with an explicit rounding mode and quantize to the required precision.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-12T09:15:15.358118+00:00— report_created — created