No Float for Money: A Guardrail Every AI Coding Prompt Needs
Ask an AI assistant to "calculate the order total" in any mainstream language and, more often than not, you will get binary floating point: double, float, number. It is the most common representation of money on the public internet, so it is the most common…
Ask an AI assistant to "calculate the order total" in any mainstream language and, more often than not, you will get binary floating point: double, float, number. It is the most common representation of money on the public internet, so it is the most.
It is also wrong for money in every regulated domain, for a reason IEEE 754 makes non-negotiable: 0.1 + 0.2 ≠ 0.3 in binary floating point. The error is tiny per operation and compounding at scale.
What Happened
Reconciliation drift, rounding disputes, audit findings. (A generation of engineers learned the failure mode from a movie: the salami-slicing scheme in Office Space is, mechanically, a rounding story.
Veracode's 2026 report findings on why models fail security tasks apply here exactly: the training corpus encodes the historical pattern, and only your stated constraint outweighs the corpus.
Across 2025–2026, the share of AI code-generation tasks introducing a known vulnerability held near 45% (Veracode, 150+ models), and AI-attributable CVEs are accelerating month over month (Georgia Tech's Vibe Security Radar: 6 in January.
Sources: Veracode, 2026 GenAI Code Security Report (2026); Georgia Tech SSLab, Vibe Security Radar (2026).
Key Details
The float made it plausible.) Two moves implement it. 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).
Every commit message in the fix was an apology.
I have chased this exact cent-drift through three different codebases over the years.
One constraint line and one type close it permanently.
Why It Matters
Binary floating point (double/float/number) for money is prohibited. Rounding: banker's rounding at aggregation boundaries only, per [your policy].
Float-money is the same phenomenon in financial clothing: a correctness constraint the corpus does not encode and the model will not supply unbidden.
Because the ambient rate of the underlying failure class is not falling.
What Reports Say
Coverage of the story so far points to:
Continued reporting by HackerNoon as more details emerge