3 ms·
Just make the smallest possible fractional cent the unit then
by lanna 7y ago
Just make the smallest possible fractional cent the unit then
- Kiro 7y agoWhat if you can't know that beforehand? E.g. if you suddenly need to charge $0.000000001 per second.
- kennu 7y agoThat works if you are 100% sure you know beforehand what the smallest possible fraction will be. What you gain by consistently using an arbitrary precision decimal library to process all monetary values, is the freedom to process smaller fractions later if necessary. Also you'll never overflow with really big values. In other words, when you represent monetary values with arbitrary precision Decimal objects everywhere, you can easily expand your application as much as you want on either side of the decimal dot. Changing existing integer-based code do to that is very error-prone, you quickly lose sight of what exactly an integer value or parameter means in different places.