Why Monetary Amounts Should Never Be Binary Floating Point

Last updated: November 29, 2026

Quick Overview

Explain why storing and computing payment amounts as double-precision floats causes defects, and describe how you would represent money, round it and convert between currencies in a Java or Python service.

Citi
Software Engineering Fundamentals
Software Engineer
Citi
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Easy

0

0

0 solved


Explain why storing and computing payment amounts as double-precision floats causes defects, and describe how you would represent money, round it and convert between currencies in a Java or Python service.

Citi's payment and ledger services are mostly Java, and an amount that drifts by a cent across millions of postings becomes a reconciliation break and an audit finding. Interviewers use this to confirm you understand number representation and the rounding rules a bank actually applies.

What the Interviewer Expects
  • Explain that most decimal fractions have no exact binary representation
  • Show a concrete failure such as 0.1 + 0.2
  • Recommend integer minor units or a decimal type with explicit scale
  • Name a rounding mode and when to round
  • Handle currencies with 0 or 3 decimal places
Key Topics to Cover
floating point
BigDecimal
rounding modes
currency precision
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • When would you use banker's rounding (HALF_EVEN) instead of HALF_UP?
  • How do you split $100 into three payments that sum exactly?
  • How should amounts be serialized in a JSON API?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

The interviewer wants three things: why floats fail, what to use instead, and the rules for rounding and FX conversion that keep a ledger balanced....

High-Level Design

A double stores a binary fraction. Values like 0.10 are repeating fractions in base 2, so the stored value is slightly off. Single operations look fine when printed, but sums over thousands of posti...


Submit Your Answer
Markdown supported

Related Questions