TravisRobson / PersonalFinance

MIT License
0 stars 0 forks source link

Modify Money class implementation to deal with fractional cents #5

Open TravisRobson opened 4 years ago

TravisRobson commented 4 years ago

Either use this actually or for inspiration https://github.com/vpiotr/decimal_for_cpp

A nice discussion for the reasons behind this: https://stackoverflow.com/questions/149033/best-way-to-store-currency-values-in-c

TravisRobson commented 4 years ago

Doubles have ~14 significant digits of accuracy. If we need ~6 decimal places worth of accuracy to handle rounding, then 8 digits are left over for the dollar amount. This leaves you in the range of +-10 million. This should be sufficient for a personal finance project.

TravisRobson commented 4 years ago

I will also need to decide how deal with rounding. You most likely don't want to round at every step of the calculation, which is currently what the money class does.