3 ms·
Really excited to see what possibilities for number handling native BigInt in JavaScript will bring https://developers.google.com/web/updates/2018/05/bigint ht
by empyrical 8y ago
Really excited to see what possibilities for number handling native BigInt in JavaScript will bring
https://developers.google.com/web/updates/2018/05/bigint https://developers.google.com/web/updates/2018/05/bigint
- zie 8y agoprobably none. To handle currency correctly you have to handle rounding to the nearest penny correctly. Computers absolutely SUCK at this, in general. So you need a Decimal library, that can handle decimal numbers. Integers ARE NOT DECIMAL. IBM has had a solution for a long time: http://speleotrove.com/decimal/ http://speleotrove.com/decimal/ Python uses it: https://docs.python.org/3.5/library/decimal.html https://docs.python.org/3.5/library/decimal.html Get a proper decimal library, and then you can devote brain cells to actual problems. The IBM link above includes links to libraries that do it right.
- village-idiot 8y agoYou can also just use the smallest unit and work in cents. The Stripe API does this instead of dealing with decimals.