Normalised Decimal Amounts for Issued Currencies on a Ledger

Last updated: November 29, 2026

Quick Overview

Issued-currency amounts on the XRP Ledger use a decimal format with a 16-digit mantissa and a bounded exponent. Implement normalisation, exact addition, and parsing from a decimal string, and explain why this design beats binary floating point for money.

Ripple
Software Engineering Fundamentals
Software Engineer
Ripple
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Issued-currency amounts on the XRP Ledger use a decimal format with a 16-digit mantissa and a bounded exponent. Implement normalisation, exact addition, and parsing from a decimal string, and explain why this design beats binary floating point for money.

Core ledger and SDK engineers at Ripple work with the ledger's custom amount types every day, and getting rounding wrong breaks consensus because every validator must compute bit-identical results. The interviewer checks number representation fundamentals, determinism, and how you reason about precision loss explicitly rather than accidentally.

What the Interviewer Expects
  • Explain why 0.1 + 0.2 != 0.3 in IEEE 754 and why that matters for balances
  • Normalise mantissa into [10^15, 10^16) with a matching exponent
  • Add by aligning exponents with exact integers, then renormalise
  • State the rounding rule explicitly and why determinism matters across validators
  • Handle zero, underflow, and overflow
Key Topics to Cover
Decimal Floating Point
Determinism
Rounding
Number Representation
Serialisation
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
  • Which rounding mode would you choose for a transfer fee, and who should bear the remainder?
  • How would you serialise this compactly in 64 bits?
  • Why does XRP itself use integer drops instead of this format?
  • How would you test that two implementations (C++ and Python) agree?
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

An amount is (mantissa, exponent) with value mantissa * 10^exponent. Non-zero amounts are normalised so 10^15 <= |mantissa| <= 10^16 - 1 and the exponent lies in [-96, 80]. Zero is canonically `...

High-Level Design

Binary floats cannot represent most decimal fractions, so 0.1 + 0.2 gives 0.30000000000000004, and different compilers or CPUs can differ in edge cases. A decimal mantissa and exponent represent c...


Submit Your Answer
Markdown supported

Related Questions