Repository navigation
Conversation
|
Hi @aytechnet! Could you let me know what the difference is between this library and the other listed alternatives? I don't want this list become just an advertisement list, but options of other libraries ppl may use and contribute to. |
|
Hi @mwoss, What it adds is mainly the shape of the type :
But using this library (and its int64 internal representation) have real trade-offs :
It's a young public project with one maintainer and few users so far, even if I started it 3 years ago to avoid memory allocation for decimal value but keeping compatibility with shopspring/decimal as well. I use it with invoicing and e-commerce software I run in production. Issues and PRs are welcome. So the use case is: you want to stay close to this library's API, and your values fit in 17 digits and memory usage is important. |
Adds aytechnet/decimal to the alternative libraries in the README.
It targets the same trade-off as govalues/decimal and udecimal: fixed, low precision for speed. Its specifics:
int64, 8 bytes and immutable, and every arithmetic operation is allocation-free. Each value has a unique representation, so==and map keys work:1.50 == 1.5.NaN,±Infand a loss flag set when rounding happened.math/bigmethods aside. Rounding (Round,StringFixed,DivRound,RoundCash,RoundBank,Truncate…) and float conversion (NewFromFloat,NewFromFloatWithExponent) are checked value by value against shopspring v1.4.0 and v1.6.0 in its test suite (bench/compare_round_test.go).Ln,SqrtandRootreturn no error, and JSON is unquoted by default.Benchmarks against v1.6.0 are in its README: 4× to 19× on fractional arithmetic and 11× to 26× on integers. The README also notes that this release narrowed the gap a lot compared with v1.4.0.
Thanks for maintaining the reference library and for keeping this list.