4 ms·
probably none. To handle currency correctly you have to handle rounding to the nearest penny correctly. Computers absolutely SUCK at this, in general. So you
by zie 8y ago
probably 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.