3 ms·
It must be tough writing code in Europe - computers only use decimal points, not decimal commas. And how do you make an international interface for money, when
by mikestew 11y ago
It must be tough writing code in Europe - computers only use decimal points, not decimal commas. And how do you make an international interface for money, when you never know how people will enter things?
I'm kind of confused as to why you're confused, so bear with me if I oversimplify, but are you aware of the globalization settings in your OS? It determines the display and entry format of things like currency. Yes, one will have to mentally switch back and forth when writing a float in code (float i = 3.14159) and paying bills with online banking ($1.345,12 sent to my mortgage company, please). But for the most part, you set bankBalanceTextField.text = $12000.01 and let the OS handle properly displaying it to the user.
To put it another way, for the globalized/localized applications I've worked on, I put a little effort into making sure it's globalizable (not hard-coding strings, not making assumptions about currency formats, make sure display fields are set to pick up display settings from OS, etc.), let the OS handle putting commas and decimal points as appropriate, and haven't had major complaints so far. No complaints, despite not having the faintest clue how currency is formatted in, say, Russia.
- ars 11y agoI don't know about you, but for me it's pretty common to output numbers that I then use in the program. So you have to distinguish between output meant for a program and output meant for human. Say someone gives you a logfile of problematic transactions - you then have to convert all the numbers to decimal points before using them in some one-off program that checks them.
- afandian 11y agoNot wishing to condescend, but where it matters, there are standard ways of doing this. For example, the standard library of .NET and Java have date format localisation so they can deal with local time zones and read and write dates. They have standard local methods for localized string joining strings, numbers and currencies. Here are two articles: https://msdn.microsoft.com/en-us/library/1ksz8yb7(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/1ksz8yb7(v=vs.110).... https://msdn.microsoft.com/en-us/library/5hh873ya(v=vs.90).aspx https://msdn.microsoft.com/en-us/library/5hh873ya(v=vs.90).a... If you don't want to write software for anyone but yourself or people in an identical environment that's fine, but if you want to write software for other people then there's lots of library support.
- mikestew 11y agoSo you have to distinguish between output meant for a program and output meant for human. That pretty much defines my career, yes. Say someone gives you a logfile of problematic transactions - you then have to convert all the numbers to decimal points before using them in some one-off program that checks them. Say someone gives me a MongoDB full of transactions that need to be transformed into relational data for our data warehouse...hey, I'll bet I could make a career out of this. I truly don't mean to be trite, but what you describe is just the way of things. In your log file example, a regex would more than likely solve the problem. One loop, a readln() and a writeln(), sorted. People do it everyday. Hell, I'll probably do something similar before the day is out.
- ars 11y agoI'm not trying to be annoying - I'm simply curious. I never had to deal with that (internally that is, I do localize for end users - but that data is one way), and I was wondering how people handled it, that's all. Sounds like it's a bit annoying, but you just deal with it because you have to. I guess it's a slight extra use of time, but nothing major?
- nl 11y agoMuch, much worse is the US mm/DD/yyyy format, especially if mixed with DD/mm/yyyy format, unlabeled, in the same file.
- ars 11y agoSee, that's kinda my question. As a programmer I refuse to use anything except yyyy-mm-dd, unless I'm forced to. So do Europeans analogously refuse to use anything except decimal points, except where they have to?
- rasapetter 11y agoAre you sure you didn't mean to write yyyy-mm-dd?