
Decimal: A high-performance, arbitrary-precision, floating-point decimal library - rbanffy
https://godoc.org/github.com/ericlagergren/decimal
======
FullyFunctional
Interesting! This appears to be implementing Decimal32, Decimal64, and
Decimal128 [1].

It's worth remembering that the "first" computer, the ENIAC, used decimal
arithmetic. A decimal arithmetic package was one of the first things I wrote
for my Z-80 homecomputer as I couldn't imagine anyone working with money using
binary floating point! [2] That said, isn't Fintech mostly using scaled
integers these days?

[1] [https://en.wikipedia.org/wiki/Decimal32_floating-
point_forma...](https://en.wikipedia.org/wiki/Decimal32_floating-point_format)
[2] My horror was refreshed recently when I compared various mortgage
calculators on the web. Not two of them got the exact same amortization
schedule :( :(

------
jakewins
The documentation says this adheres to the `math/big` API in some respects -
can someone speak to what differentiates this from `math/big`?

~~~
friday99
It deals with floating-point, arbitrary-precision decimal numbers, whereas
math/big contains support for arbitrary-precision integers, rationals and
binary floating point. Looking at it briefly, it looks like it uses math/big
under the hood when the numbers are large, but uses an internal compact form
for efficiency when numbers are small ~<= 20 decimal digits.

~~~
barsonme
Yep! That’s what it does. Hopefully I can get it moved over to BCD which will
drop basic arithmetic performance, but more than make up for it when faster
rounding. :-)

------
apaprocki
(Related topic) Since this might gather eyeballs that would like to see
decimal support in JS, I'd be interested to hear more details about use cases
people have for this Go package as well as potential use cases / interop in
JS.

------
irfansharif
As a plug for another arbitrary-precision, floating-point decimal library in
Go, there's
[https://github.com/cockroachdb/apd](https://github.com/cockroachdb/apd).

------
dang
Original URL was
[https://github.com/ericlagergren/decimal](https://github.com/ericlagergren/decimal),
but the doc page has more info.

------
StillBored
Odd. I had to spend 5 minutes convincing myself from the site (which uses the
same wording) that it was actually a 'decimal floating point' library, as I've
never heard such a thing called a 'floating point decimal'.

