Interview practice question
Money stored as floating-point numbers
Backend Engineering · OOP and Design Patterns · Intermediate
Your code stores prices as doubles, and customers see totals like 19.999999. How would you fix this in the design?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Floats can't represent decimals exactly.
- Money value object.
- Integer minor units or decimal type.
- Currency included; operations enforce same currency.
- Explicit rounding rules.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.