Ask any AI coding assistant to calculate an order total and it will almost certainly reach for double, float, or number. That is the most common representation of money in the training corpus. It is also the wrong answer for any financial context, because IEEE 754 makes one thing non-negotiable: 0.1 + 0.2 does not equal 0.3 in binary floating point.
The error is tiny per operation. At scale, it compounds into reconciliation drift, rounding disputes, and audit findings. The author of the source piece traces the principle to a rule called Delta’s Law 5: “No float for money. No exceptions.”
Fix 1: One line in your prompt constraints
The model will not honor a constraint it never received. The recommended addition to any prompt that touches monetary values:
Monetary values MUST use exact decimal representation (C#: decimal; Java: BigDecimal or integer minor units; Python: decimal.Decimal; TypeScript/JS: integer cents or a decimal library). Binary floating point (double/float/number) for money is prohibited. Rounding: banker’s rounding at aggregation boundaries only, per [your policy].
That single constraint changes what a plausible completion looks like. Veracode’s 2026 report on AI code security found that models fail correctness constraints because the training corpus encodes historical patterns, and only a stated constraint outweighs the corpus.
️ Fix 2: Make the type system enforce it
Prompt constraints steer generation. Types catch what steering misses. The pattern is a domain Money type whose float-based constructors are marked unusable at the compiler level:
- C#: An
[Obsolete(error: true)]constructor takingdouble, so any attempt to buildMoneyfrom a float fails to compile with a message explaining why. - Java: A
Moneywrapper overBigDecimalor long-cents with no float factory method. - Python: A
Moneydataclass that raises on float input. - TypeScript: A branded
Centsinteger type.
An MIT-licensed companion repository covers all four implementations with tests.
Why the numbers make this urgent
Across 2025 and 2026, roughly 45% of AI code-generation tasks introduced a known vulnerability, according to Veracode’s report covering 150+ models. Georgia Tech’s Vibe Security Radar tracked AI-attributable CVEs accelerating from 6 in January 2026 to 35 by March 2026. Float-money is the financial domain version of the same pattern: a correctness constraint the corpus does not encode and the model will not supply on its own.
The two-part fix (prompt constraint plus poisoned constructor) converts the failure mode from silent cent-drift to a compile error. That is the cheapest class of failure you can have.
