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
-
mryamz4467ySometimes, 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:
1 000,00
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 ?! -
@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. -
Fradow9087yIf 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.
Related Rants
I started thinking and worrying about numbers much more than before
in the US, you write numbers like this:
1,000.00
in Germany usually like this:
1.000,00
and in programming languages like this:
1000.00
now i wonder how to type a number, whenever i have to use german software
should i use the US way, the german way or the dev way? the wrong one could possibly break it
undefined
germany
wk59