Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
mryamz4654ySometimes, depending on the programming language, I write numbers with underscores e.g 1_000 or 1_000_000
My issue is that I need to deal with 23 different currencies and format them to the user... There are surprisingly a lot of combinations, formats and characters
And in Slovakia we do:
I actually think spaces make the most sense for thousand spearators. For decimals I don't care.
But why can't there be a standard way ?!
But the thousands seperator is not mandatory.
@CogInTheWheel Luckily, most programming languages have good libraries to do datetime formatting, currency and number representations.
For web stuff it's float in db (optionally two fields, like amount and currency_type), float in backend, and then depending on your convictions you either serve a formatted string (add symbols, round etc) or let the frontend handle it.
The other way around (user input) you assume they enter a float, preferably helping them with some visual aids, then sanitize only if you can be certain of meaning, and reject the rest in backend validation.
arcc1714yLet's make this a standard, 1,0,0,0,0,0.0,0
Fradow9854yIf you are USING software, you should use your current locale way of formatting numbers. If that doesn't work, use the locale of the software's company (generally US/UK way), because they probably didn't use a good library.
If you are DEVELOPING software, use a library that handle locales for you. I know iOS and Android handle that pretty well, I guess you can find good library for every OS / language.
Oversmart354yUse scientific notation. You can never go wrong
h4xx3r17134y1) Just force the end user to apply to a certain kind of input.