Decimal rounding strategies in enterprise applications

和自甴很熟 提交于 2019-12-06 01:55:11

You should store the number exactly as you want it to be reflected on their balance.

Are you actually charging the customer the half-cent? If you are, it should be reflected in the DB entry. If you're not, then it shouldn't.

But unless I were posting accrued interest daily (like Prosper.com for example) I would stick with units of currency that people can pay (or withdraw) exactly.

It depends what is more important. But ususally if you doing a accounting or invoicing system, conciliation of balances is an important goal. So for this reason I would store the rounded value.

I'd save both (seriously).

Store both. Your customers will not be able to pay the non-rounded amount by credit card anyway, but your books need to be correct.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!