What are the best practices passing dollar amounts in JSON?
Passing the amounts as strings, or floats? or other?
We are a bit worried about round off errors displayed on client (iOS / Android / Web), or possibly different values displayed on one client compared to another.
I think one solution is to pass the amount times 100 as an integer
(No rounding errors, safe storage in database, unless you need more decimals if you use this in currency exchange market for example).
That way you can manipulate your amounts (addition or multiplication,..), and to display it juste divide again by 100.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With