Skip to content

Library uses float which causes rounding errors #63

@Talljoe

Description

@Talljoe

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

Metadata

Metadata

Assignees

Labels

V4v2021-02-25 Client

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions