3 ms·
This makes me wonder why Decimals aren’t part of std libs in Javascript or Golang.
by parhamn 4y ago
This makes me wonder why Decimals aren’t part of std libs in Javascript or Golang.
- lifthrasiir 4y agoIt is hard to design. There should be some sort of precision and rounding mode control throughout calculation, meaning there should be some sort of implicit state or those controls should be sprayed into every operation. The latter is explicit but tedious [1]. The former will still surprise people from time to time. IEEE 754 binary number is sort of working well in this aspect. [1] See QuickJS's BigDecimal extension for example: https://bellard.org/quickjs/jsbignum.html#Properties-of-the-BigDecimal-object https://bellard.org/quickjs/jsbignum.html#Properties-of-the-...
- ClumsyPilot 4y agothat's eactly why it needs to be in standard library- so people dont make mistakes reinventing the wheel
- lifthrasiir 4y agoOnly if you have a proven design. I don't think we have any satisfactory design at all.
- ClumsyPilot 4y agoWhat's wrong with https://en.m.wikipedia.org/wiki/Decimal64_floating-point_format https://en.m.wikipedia.org/wiki/Decimal64_floating-point_for... Or with C# 128 bit implementation of decimal? Is there no good implementation anywhere?