5 ms·
This is unrelated, but that has to be the most confusing way to write a price I've ever seen: 2.699,00 - a period for the thousands separator, and a decimal com
by ars 11y ago
This is unrelated, but that has to be the most confusing way to write a price I've ever seen: 2.699,00 - a period for the thousands separator, and a decimal comma for the cents.
I am aware of decimal commas - but a period for the thousands? I thought they used a space, or an apostrophe? 2'699,00
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?
- mynegation 11y agoYes, period for digit separator is a thing in many countries, including Russia, we were taught that way in school [1] It was a little bit inconvenient when I started programming, but nothing too major. Interface for money and many other things is a solved problem: we have locale settings for that in operating systems and software that respects them, works just fine. [1] https://en.wikipedia.org/wiki/Decimal_mark#Examples_of_use https://en.wikipedia.org/wiki/Decimal_mark#Examples_of_use
- deleted 11y ago[deleted]
- chinathrow 11y agoThat's common. 18 hits in: http://www.thefinancials.com/Default.aspx?SubSectionID=curformat http://www.thefinancials.com/Default.aspx?SubSectionID=curfo... Writing code is not that tough in Europe - just use a proper i18n library.
- davidw 11y ago> Writing code is not that tough in Europe - just use a proper i18n library. Not even having to think about that initially is sure handy for US startups. You can get pretty big without worrying too much about other languages and all the confusion that entails.
- chinathrow 11y agoTrue - until you go north and need a french translation ;)
- davidw 11y agoSpanish is probably more likely in the US, depending on the market you're addressing.
- logfromblammo 11y agoEnglish, Spanish, French, Portuguese, and to a lesser extent Dutch will get you pretty much the entire western hemisphere. They all use the same alphabet, all read left-to-right, and are all SVO word order--except for Dutch, which is SOV/V2. Also, a US company will need a Spanish translation before it even considers French. Anyway, the point is that it is a lot easier to half-ass internationalization and localization for both of the Americas and the Caribbean than it is in Europe and Asia. That is just indisputably true. European coders must get that correct starting from version 1.0, whereas Americans can blithely ignore it for years.
- ars 11y ago> Writing code is not that tough in Europe - just use a proper i18n library. That only goes so far - the actual code you write has to use decimal commas. You can't even export, say a list of numbers, and then directly copy that in to your code. Or for example: Use SQL to print a list of numbers to use for testing queries. If you used i18n, all the numbers would have decimal commas, so you can't combine them with a comma to make a list. So you have to turn off i18n, print your list, and make sure it's off when you use that list in a subsequent query. Any European programmers here? Do you simply leave i18n off for all low level tools? And just use it for customer facing code?
- untog 11y agoHuh? That's not the case at all. Numbers are represented the same way as in the US throughout your code, your just put it through an i18n library when presenting it to the user. It's really not as difficult as you're making it out to be.
- ars 11y ago> when presenting it to the user. That's what I mean - sometimes the user is you, i.e. the programmer, and you have to put those number back in the program - but of course you have to convert them first. > It's really not as difficult as you're making it out to be. Not ever having done it, I will take your word for it.
- kpil 11y agoYes. Minor haggles occur when importing numbers into code , but all good tools can export to whatever format. Typically the internal representation is not related to the external format. But yes there are bugs in (American) programs sometimes that forces you to run them in the C locale. Typically they serialise something and fails parsing it back...
- imtringued 11y agoI'm not sure what's so difficult to understand about calling a function like parseInteger(userEnteredNumber, defaultLocale) on user input and then calling something like formatInteger(numberToBeOutputted, defaultLocate) on numbers that will be shown to the users. Programming languages already have a fixed representation for decimal numbers that will be used regardless of the user locale which is generally always with a dot for the decimal seperator and often there are no thousand seperators.
- jggonz 11y agoHi ars, this is an article that discusses your concerns: http://www.xencraft.com/resources/multi-currency.html http://www.xencraft.com/resources/multi-currency.html Take a look at the section titled "Presentation Formats"
- jwdunne 11y agoOh yes, it's a thing. I remember being really interested in a sign outside a pub in the Canary Islands that listed a beer as 2,00 or similar. Then I noticed it everywhere and realised the convention I'm used to is reversed there. Sorta like being British and looking both ways at a road in a foreign country!
- athenot 11y ago«computers only use decimal points, not decimal commas» That's what localization is all about: eliminating these false assumptions. It's only confusing when you're not used to it. On a similar note, 12-hour time notation (eg. 3pm) is confusing as heck when you're used to 24 hour notation.
- ars 11y ago> That's what localization is all about: eliminating these false assumptions. I've never seen a production compiler use anything except decimal points. So writing code that outputs code must be extra confusing: Turn off localization for the parts meant for the computer, and turn it on for the parts meant for humans.
- athenot 11y agoWell here's the thing: decimal points are for humans in the first place. Computers use fixed, floats or whatever binary representation that suits the needs of the environment.
- wyldfire 11y ago> I've never seen a production compiler use anything except decimal points. There's a distinction between literals used in programming languages and how various input/output routines emit different numerals. Most programming languages follow the convention: a '.' for a radix symbol and no thousands separator. Many programming languages also include: explicit '.' implies a floating-point numeral, scientific notation support. Most modern programming languages (and even some older ones) have standard library or extremely popular library support for localization. That localization will customize things like the radix and thousands separator. Some languages support custom literals, so you probably could adapt it to match your locale if the grammar doesn't somehow become ambiguous. Other interesting stuff literals sometimes include: different numeral bases, signedness, precision. It doesn't seem confusing to me, but I'll admit that there have probably been many times that I could take advantage of the programming languages' support for parsing literal numerals whose format happens to match my locale's (en_US.*).
- rikkus 11y agoI can't tell if the parent is a joke. If not, I should tell you that decimal separator is usually regarded as variable and therefore just part of local representation, in a similar way to time and date formats. Plenty of code is only able to cope with a particular representation, or has bugs around dealing with varying ones.
- ars 11y agoI'm mostly talking about the programmer, not the presentation. You need one kind of number for the program, another for humans.
- mikestew 11y agoIt 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.
- dang 11y agoWe detached this subthread from https://news.ycombinator.com/item?id=11581036 https://news.ycombinator.com/item?id=11581036 and marked it off-topic.
- ars 11y agoSorry, I didn't expect the subthread to get that long.
- dang 11y agoThese things happen. Off-topic musings are often just fine, but if the subthread gets too heavy it's best to prune it.
- Karunamon 11y agoOut of curiosity, what does marking a subthread off topic entail?
- dang 11y agoIt makes it rank lower.