Healthesystems Interview Question

What variable type would you use for currency?

Interview Answer

Anonymous

Jan 12, 2018

BigDecimal. They actually argued using floating point was OK with rounding. They must not be aware floats and doubles cannot accurately represent the base 10 multiples that is used for money. This issue isn't just for Java, it's for any programming language that uses base 2 floating-point types.