5 ms·
Decimal.js, arbitrary-precision decimal type for JavaScript
- rpedela 12y agoThis is great! Proper support for this has been lacking in the Node world. I recommend json-bignum [1] if you need a Node library for JSON serialization that can handle large numbers. For example, retrieving a JSON-formatted row from Postgres which has int64 or numeric values. It is slower than the native JSON functions though. 1. https://github.com/datalanche/json-bignum https://github.com/datalanche/json-bignum Disclaimer: I wrote json-bignum.
- bigdubs 12y agoReading the ReadMe.md makes me wish that javascript let you overload / implement operators. Type looks cool though
- neals 12y agoHoping somebody could explain to me why methods are written like so: P['absoluteValue'] = P['abs'] = function () { } instead of P.absoluteValue = p.abs = function () {}
- goblin89 12y agoIndeed. And, interestingly, Decimal.format (alone?) is declared with dot notation[0]. Overall coding style feels relatively consistent so there must be some reasoning behind these decisions. [0] https://github.com/MikeMcl/decimal.js/blob/master/decimal.js#L3957 https://github.com/MikeMcl/decimal.js/blob/master/decimal.js...