Financial & Rounding Semantics · Delphi → C# / Java / C++
Delphi System.Round banker's rounding and silent uses shadowing.
Financial and ERP migrations rarely fail on whole dollars — they fail on half-cent tie-breaking and silent identifier shadowing hidden in a unit's uses clause.
Two separate traps around Round(x)
- 01 · Banker's rounding (half to even) under default FPU mode
System.Round(2.5) = 2andSystem.Round(3.5) = 4. That matches C# defaultMath.Round(x)(MidpointRounding.ToEven), but silently diverges from C++std::round(half away from zero) and JavaMath.round(half toward +∞). Worse: Delphi's rounding mode can also be mutated at runtime viaSystem.Math.SetRoundMode(Contract Dimension #2: hidden external FPU state). - 02 · Silent shadowing via the
usesclauseIn Delphi, later units inusesshadow earlier ones (includingSystem). If a legacy helper unit declares its own commercial half-upfunction Round(Value: Double): Int64;, every unqualifiedRound(x)in that unit silently stops callingSystem.Round— and an AI agent reading a single procedure out of context will port the wrong rounding law!
Verification checklist before porting financial code
- Resolve the fully qualified target of every
Roundcall against the fulluseslist (Contract Dimension #3). - Search the codebase for
SetRoundMode/Set8087CW/SetMXCSR(Contract Dimension #2). - Check whether Win32 80-bit
Extendedintermediate sums are being compared against 64-bit IEEEDoubleor C#decimal(see Extended Win32 vs. Win64 guide).
Verify it yourself in Delphi 13 (Free < 1 MB Demo)
Every rule in these guides comes from 879 build observations and 650 executable runs on Delphi 13 Community Edition (Win32, Win64, and compile-only Android ARM). The free demo on GitHub includes the complete 74-chapter & 89-directive Table of Contents, 6 multi-difficulty excerpts, 4 complete directive cards, 8 compiler JSON receipts, 6 runnable .dpr probes, and working plugins, skills, and local offline MCP server.
Get Full Universal Suite · from $99Inspect Free Demo on GitHubAll Technical Guides
Honest scope boundaries: Strictly a Delphi / Object Pascal language, runtime-behavior, and compiler-directive reference — not a VCL, FMX, or FireDAC component API encyclopedia. Does not claim 100% coverage of the language or any ABI; open questions are listed explicitly by name. Independent product, not affiliated with Embarcadero Technologies, Inc.