Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Customer was charged $0.995 after fees, how to represent in your data model with integer cents?


You'll have to decide when and how to round. Keeping individual billing items at high precision and rounding after summing them up can work; defining and documenting a rounding policy (or complying with whatever's legally required in your jurisdiction/domain) and rounding each individual billed item can as well.


Currency: USD Amount: 99500 Decimals: 5


Congrats m8 you invented floating point


Then you have no idea how floating point works. (Hint: its in the name)


You use 1/1000th or 1/10000th or whatever you need. You do not need “cents”.


How is the client going to pay that? They can't be charged half a cent.


Round it up


Charge $0.995

Refund $1.00

Repeat


Charge $0.995

Charge Actual $1.00

Refund $1.000

Alternately

Charge $0.995

ERROR CHARGE AMOUNT MUST BE ROUNDED TO NEAREST CENT


In my scenario your payment gateway added a $0.005 fee. You told it $0.99.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: