Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library uses float which causes rounding errors #63

Open
Talljoe opened this issue Oct 27, 2020 · 3 comments
Open

Library uses float which causes rounding errors #63

Talljoe opened this issue Oct 27, 2020 · 3 comments
Assignees
Labels
V4 v2021-02-25 Client

Comments

@Talljoe
Copy link

Talljoe commented Oct 27, 2020

Describe the bug

The Go library uses float for monetary values. Float is widely discouraged as it does not contain the necessary precision to handle currency values.

To Reproduce

Fetch a credit invoice of $-79.99. Multiply by 100.0 and convert to an `int:

// invoice.Subtotal = -79.99
x = int(invoice.Subtotal * 100.0)
assert.equal(-7999, x)
Error: Not equal:
       expected: -7999
       actual  : -7998

Expected behavior

Library should use a Decimal or other fixed-point

Your Environment

  • Which version of this library are you using? v3.8.0 f4d23f4
  • Which version of golang are you using? 1.14.9
@douglasmiller douglasmiller self-assigned this Oct 28, 2020
@douglasmiller
Copy link
Contributor

Thank you for reporting this @Talljoe. We are aware of this limitation and are investigating solutions that we can employ in our upcoming 4.x client release. Updating the 3.x client would introduce a breaking change to existing implementations, unfortunately. We will leave this issue open and will provide updates when they become available.

@jguidry-recurly jguidry-recurly added the V4 v2021-02-25 Client label Feb 12, 2021
@speza
Copy link
Contributor

speza commented May 10, 2021

Have there been any updates on this @douglasmiller?

@wellsync-matt-may
Copy link

This was 4 years ago and it's still not fixed in the product? I just submitted a support ticket. This issue results in incorrect billing calculations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V4 v2021-02-25 Client
Projects
None yet
Development

No branches or pull requests

5 participants