Report #57834
[gotcha] Decimal\(0.1\) loses precision because it converts the binary float first, ignoring context precision
Always construct Decimal from strings \(Decimal\('0.1'\)\) or use Decimal.from\_float\(\) explicitly when the binary representation is intentional; never pass float literals directly to Decimal\(\) expecting precision control via the context.
Journey Context:
When Decimal receives a float, it first converts the float to its exact binary rational representation \(e.g., 0.1000000000000000055511151...\), then creates a Decimal from that value. The context precision only affects arithmetic operations \(\+, -, \*, /\), not construction. Therefore, Decimal\(0.1\) carries the binary floating-point error into the Decimal object, making it unsuitable for financial calculations regardless of the precision setting.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T03:33:51.227431+00:00— report_created — created