Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I would totally go the decimal way. Set the constraints to only allow 2 digits after the semicolon. I think it's way less error-prone
-
Store in the lowest unit of your currency as an int.
EG:
£123.99 -> 12399
£0.01 -> 1
Simply convert all values to a double or float and times by 100 when you want to render the value as cash. -
botti5117y@DeadInside, not allowed to ask questions on devRant? To get advice from fellow developers? :)
-
@botti didn't say you weren't allowed. Who am I to tell you how to use it? I don't set the rules. I'm just inflicting my own desires for the community to not to loose its focus on being a forum for rants and mutual (emotional) support rather than tech support.
Related Rants
Hmmm, doing a little side project which requires me to store "money" I am uncertain if the approach should be integers with cents or dollars as decimals (19,4) in a MySQL/php project.. Any thoughts?
undefined
question
help
uncertainty