recurly/recurly-client-java

Use BigDecimal instead of Float for currency values

brianlenz opened this issue · 1 comments

Describe the bug

Java's floating point values (specifically, the float primitive) are naturally lossy by design. They aren't guaranteed to represent all values with total accuracy, so it's a particularly bad choice to use with currency values where precision is critical.

In light of this, Recurly should change all float/Float values in the SDK to use BigDecimal instead, which has guaranteed precision and is therefore a much better option for storing currency values.

Expected behavior

All currency values should be guaranteed since we're dealing with financial transactions.

Thank you for reporting this, @brianlenz. We are aware of this issue and are planning to make this update in the 4.x client release that should be coming soon. We cannot make the change to BigDecimal in the 3.x clients as it would be a breaking change.