• (cs)

    That's kinda sad.

  • PS (unregistered)

    Another post about that Europe place. If they don't speak English then how do you expect them to understand the correct usage of commas and decimal points. I do understand that those Europe people probably need the comma between the dollars and the cents because they probably need a small pause between the dollars and the cents to sing a few lines from "The Final Countdown".

  • (cs)

    I like the fact that any other character than dot or comma will lead to a run-time error (I've seen the apostrophe used as a decimal separator in some places). For the rest, I find this code very considerate and respectful to other cultures and not a total waste of CPU cycles at all.

  • (cs) in reply to PS
    PS:
    I do understand that those Europe people probably need the comma between the dollars and the cents because they probably need a small pause between the dollars and the cents to sing a few lines from "The Final Countdown".

    As a Dutchman myself, I can verify that this is the absolute truth, and it happens, interestingly, every time I go shopping and pay with US dollars.

  • JernejL (unregistered)

    there are 2 comments!

  • Macgyver (unregistered)

    I can't think of any reason to use a string. I mean, he/she obviously brought currentValue in as a decimal, so why not just set maxValue as a decimal as well, it's already essentially a constant. Or assign it a value in a bundle dependent on the language in use on the machine. Then you wouldn't have to worry about whether or not a comma or decimal was there.

    captcha: Dreadlocks. ya man.

  • (cs)

    That's why every programmer should first learn low-level languages, and exercise himself in manipulating integers, floats, fixed points numbers and strings, converting one type to another in assembly. That's the kind of mistake you make if you have no clue about how variables are stored in memory. So he thought numbers need to be localized before comparisons.

    Joel Polsky regularly writes about that matter. This programmer must be proficient in writing "Shlemiel the painter's algorithms"

    http://www.joelonsoftware.com/articles/fog0000000319.html

  • warren (unregistered)

    The Real WTF is that "System.Globalization" uses United States-centric spelling!

  • (cs)

    Reminds me of where i work.... We have a asp.net website and one of my coworkers thought it would be a good idea to split a date from the datasource with a method he has written himself. Unfortunately, i have a browser with english as default language and the website's language was set to "autosensing", so the whole app crashed...

  • (cs) in reply to PS
    PS:
    those Europe people probably need the comma between the dollars and the cents because they probably need a small pause between the dollars and the cents to sing a few lines from "The Final Countdown".
    That was the first post I've ever seen on this site that literally made me laugh out loud.

    On topic, though, once I saw that it was a post about decimal/comma issues I just knew the poor bastard was storing the number as a string and then converting it back. And sure enough.

    People who can't use Google amaze me sometimes.

  • (cs)

    I may be missing something, but why are globalization settings set by CurrentThread? Are they worried one thread might be in a different country than another?

  • Brit (unregistered) in reply to iceburg
    iceburg:
    I may be missing something, but why are globalization settings set by CurrentThread? Are they worried one thread might be in a different country than another?

    Absolutely, what with this new fangled web thing...

  • (cs) in reply to PS
    PS:
    Another post about that Europe place. If they don't speak English then how do you expect them to understand the correct usage of commas and decimal points. I do understand that those Europe people probably need the comma between the dollars and the cents because they probably need a small pause between the dollars and the cents to sing a few lines from "The Final Countdown".

    For no reason other than it makes me laugh:

    "What" ain't no country I ever heard of. Do they speak English in "What"? English, mf, do you speak it? </PulpFictionQuote>

  • Gijs (unregistered)

    Uch, different decimal signs... One of the greater annoyances when working with Microsoft apps (which says quite a lot!). Try importing numbers you've just exported from a European version of Excel into Access, or writing Access queries - you need to use American style in all VBA code and (I believe) queries, but everything else, including its output, uses European style. Gaah! Especially when you use an American version of these programs, and your users have a Dutch version... Causes some "interesting" errors...

  • Trinian (unregistered)

    m is for moron

  • Rory Parle (unregistered)

    Bizarrely, iTunes had just decided to start playing The Final Countdown when I clicked through to the comments.

  • (cs) in reply to fennec

    A parable about globalization:

    My last company had all their firmware engineers in France. They decided to lay off everyone in France and build a firmware engineering group in house in California.* Unfortunately for them, the firmware was written half in assembly, and all the function names were in French! HA HA!

    • The first time the company's engineering director came to visit our site after they bought us out, the first slide bragged about how much money was saved by laying off the French engineers.
  • Ashley Frieze (unregistered) in reply to Brit
    Brit:
    iceburg:
    I may be missing something, but why are globalization settings set by CurrentThread? Are they worried one thread might be in a different country than another?

    Absolutely, what with this new fangled web thing...

    Just in case the original poster was actually looking for some useful feedback, and in case the comments of Brit didn't give it:

    1. In Windows each process can have its UI set to a different culture - this tends to be done by setting the default locale of the UI thread.
    2. In a web server, the thread handling the building of an outgoing web page might well set its culture to that which is most compatible with the language that the browser is in.

    The thing is that you shouldn't have to worry about the culture of your numeric constants, given that your program's source code doesn't get reinterpreted at runtime... though that would be more fun!

  • Youssef (unregistered)

    Well, here's a capthca for you guys that I bet none of you thought of: In Arabic, the comma is actually the decimal separator. Meaning that 9.5 is written as 9,5 - simply because the dot represents the zero number. To make it easier for you to understand, the funniest part is that Arab people do not use the Arabic numbers, we use Hindi numbers. In Hindi number, the zero is represented as a dot: 1000 = 1... 1000.5 = |...,O (yes, five looks more like an O in Hindi - and one is just a straight line. They're still represented as 1 and 5 in your integer though)

    When applying regional settings and setting the regional settings to any Arabic country, this will be active immediately in Windows.

  • not a phb (unregistered) in reply to iceburg
    iceburg:
    I may be missing something, but why are globalization settings set by CurrentThread? Are they worried one thread might be in a different country than another?
    Imagine one of them border guard shacks... the computer is sitting right on the border. The dual core chip is literally placed such that each core is in another country. Depending upon random scheduling, the output could vary wildly.

    Needs a tri-bool!

  • not a phb (unregistered) in reply to iceburg
    iceburg:
    I may be missing something, but why are globalization settings set by CurrentThread? Are they worried one thread might be in a different country than another?
    Imagine one of them border guard shacks... the computer is sitting right on the border. The dual core chip is literally placed such that each core is in another country. Depending upon random scheduling, the output could vary wildly.

    Needs a tri-bool!

  • not a phb (unregistered) in reply to not a phb

    Gaah - what gives with the double posts? The forum used to prevent that from happening. Alex?

  • (cs) in reply to Brit
    Brit:
    iceburg:
    I may be missing something, but why are globalization settings set by CurrentThread? Are they worried one thread might be in a different country than another?

    Absolutely, what with this new fangled web thing...

    ... In Soviet Russia, threads run YOU!!!!

  • betlit (unregistered)

    i had a nice WTFish experience on ebay a couple years ago.

    in switzerland, we use of course the correct decimal and thousends separators. one thousdand two hundred and thirty four point five is written 1'234.5

    i wanted to spend some swiss francs (you know.. just like dollars.. but different) on an cheap item and entered 8.50 or something.

    problem is: ebay seem not to have made a difference between switzerland and germany where the notation 1.234,5 is used.

    so my offer for some cheap sunglasses was 'correctly' recognised as 8.500 swiss francs. after all i did enter a thousand separator so i must have meant 8.500 :)

  • (cs)

    I just don't like commas used in place of dots, but it may have more to do about stuff I read translated in Spain (instead of locally in Mexico) and getting all terms ugly (like "ordenador" instead of "computadora" or even uglier "translations"). One of the giveaways was the inverted use for commas and dots.

    BTW, I had one of those format conversion snafu's in my old job. Someone complained that SAP R/3 was barfing on the input.

    Turns out the regional settings for that particular PC were set to Spain, but R/3 works with the dot-separator mode. Copy-pasting that Excel output gave everything in the comma-separated mode...

  • Iceman (unregistered) in reply to Youssef
    Youssef:
    Well, here's a capthca for you guys that I bet none of you thought of: In Arabic, the comma is actually the decimal separator. Meaning that 9.5 is written as 9,5 - simply because the dot represents the zero number. To make it easier for you to understand, the funniest part is that Arab people do not use the Arabic numbers, we use Hindi numbers. In Hindi number, the zero is represented as a dot: 1000 = 1... 1000.5 = |...,O (yes, five looks more like an O in Hindi - and one is just a straight line. They're still represented as 1 and 5 in your integer though)

    When applying regional settings and setting the regional settings to any Arabic country, this will be active immediately in Windows.

    Nonsense. Hindi 0 does not look like a dot, nor does 5 look like O. http://www.anu.edu.au/asianstudies/hindi/tech/ANU_Hind_layout.png

  • European (unregistered) in reply to PS
    PS:
    Another post about that Europe place. If they don't speak English then how do you expect them to understand the correct usage of commas and decimal points. I do understand that those Europe people probably need the comma between the dollars and the cents because they probably need a small pause between the dollars and the cents to sing a few lines from "The Final Countdown".

    You, Moron!! The same way you don't fucking use the bloody metrical system (inches... measured from a King's hand... ha!) we use diverse decimal separators. And also use something different from you: the BRAIN!

    BTW, start mocking other nations when yours get something like a decent history... At least, our forefathers weren't outcasts come from England's jails ¬¬

    (captcha: darwin.... and guys like this not being at darwinawards.com ¬¬)

  • woops... (unregistered) in reply to iceburg
    iceburg:
    I may be missing something, but why are globalization settings set by CurrentThread? Are they worried one thread might be in a different country than another?
    Imagine you need to parse a file in a thread with country aware settings other than what the app usually runs under, e.g. because the file is definitely from another country. Would you then set a globally - valid for all threads - setting of the country, all other threads would misfunction as long as this one parses the said file.

    captcha: onomatopoeia ... the disease those people suffer from

  • (cs) in reply to European
    European:
    PS:
    Another post about that Europe place. If they don't speak English then how do you expect them to understand the correct usage of commas and decimal points. I do understand that those Europe people probably need the comma between the dollars and the cents because they probably need a small pause between the dollars and the cents to sing a few lines from "The Final Countdown".

    You, Moron!! The same way you don't fucking use the bloody metrical system (inches... measured from a King's hand... ha!) we use diverse decimal separators. And also use something different from you: the BRAIN!

    BTW, start mocking other nations when yours get something like a decent history... At least, our forefathers weren't outcasts come from England's jails ¬¬

    (captcha: darwin.... and guys like this not being at darwinawards.com ¬¬)

    Heh, here in Mexico we use the Metric System ... and dots for decimal separation. I prefer dots for separation, but it is basically because that's how I was thought to do.

    Oh yeah, and the metric system rules!! At least I don't have to learn wacky unit equivalencies (12 inches are a feet? huh?) Everything in the metric system is ... well... metric. (Base 10).

  • Youssef (unregistered) in reply to Iceman

    Maybe you need to look here: http://en.wikipedia.org/wiki/Arabic_numerals#Evolution_of_symbols

    I should have been more percise - Arabic-Indic numerals in what's used in everyday's life in all 22 Arab countries.

  • (cs) in reply to European
    European:
    You, Moron!! The same way you don't fucking use the bloody metrical system (inches... measured from a King's hand... ha!) we use diverse decimal separators. And also use something different from you: the BRAIN!

    Are you trying to make sense here? You completely missed the joke about the band 'Europe' and made yourself look like a jingoistic moron. I think you'd fit in well with the American attitutde you purport to detest.

    BTW, start mocking other nations when yours get something like a decent history... At least, our forefathers weren't outcasts come from England's jails

    That's Australia.

  • Youssef (unregistered) in reply to Iceman
    Iceman:
    Youssef:
    Well, here's a capthca for you guys that I bet none of you thought of: In Arabic, the comma is actually the decimal separator. Meaning that 9.5 is written as 9,5 - simply because the dot represents the zero number. To make it easier for you to understand, the funniest part is that Arab people do not use the Arabic numbers, we use Hindi numbers. In Hindi number, the zero is represented as a dot: 1000 = 1... 1000.5 = |...,O (yes, five looks more like an O in Hindi - and one is just a straight line. They're still represented as 1 and 5 in your integer though)

    When applying regional settings and setting the regional settings to any Arabic country, this will be active immediately in Windows.

    Nonsense. Hindi 0 does not look like a dot, nor does 5 look like O. http://www.anu.edu.au/asianstudies/hindi/tech/ANU_Hind_layout.png

    Maybe you need to look here: http://en.wikipedia.org/wiki/Arabic_numerals#Evolution_of_symbols

    I should have been more percise - Arabic-Indic numerals in what's used in everyday's life in all 22 Arab countries.

    That being said - you can see clearly in this image http://www.datacal.com/products/arabic-keyboards_l.htm that the dot cannot be used as a separator in Arabic-Indic numerals since it is really the zero number.

  • Anon (unregistered) in reply to Digitalbath
    For no reason other than it makes me laugh:

    "What" ain't no country I ever heard of. Do they speak English in "What"? English, mf, do you speak it? </PulpFictionQuote>

    That always makes me laugh.

  • (cs) in reply to Rory Parle
    Rory Parle:
    Bizarrely, iTunes had just decided to start playing The Final Countdown when I clicked through to the comments.

    The real WTF is that your using ITunes! blah blah

  • (cs)

    Where's the WTF here? This is the only locale-safe way to write a range comparison. What if there's this little nation somewhere, where < is used instead of > and viceversa?

    Oh, and before someone jumps up the gun and calls me a moron: http://en.wikipedia.org/wiki/Sarcasm

  • (cs) in reply to not a phb
    not a phb:
    iceburg:
    I may be missing something, but why are globalization settings set by CurrentThread? Are they worried one thread might be in a different country than another?
    Imagine one of them border guard shacks... the computer is sitting right on the border. The dual core chip is literally placed such that each core is in another country. Depending upon random scheduling, the output could vary wildly.

    Needs a tri-bool!

    It's even worse when one country changes to DST and the other one doesn't. Then you get some really interesting threading issues.

  • orangeyoda (unregistered) in reply to mkb
    BTW, start mocking other nations when yours get something like a decent history... At least, our forefathers weren't outcasts come from England's jails

    That's Australia.

    The religious nuts the English pushed off Plymouth docks, went to America. Where else do they worship a Turkey?

  • (cs) in reply to orangeyoda
    orangeyoda:
    The religious nuts the English pushed off Plymouth docks, went to America. Where else do they worship a Turkey?

    The parent poster will kindly note that we did NOT take Benjamin Franklin's suggestion of the wild turkey as our national emblem.

  • Gedoon (unregistered) in reply to dhromed
    dhromed:
    PS:
    I do understand that those Europe people probably need the comma between the dollars and the cents because they probably need a small pause between the dollars and the cents to sing a few lines from "The Final Countdown".

    As a Dutchman myself, I can verify that this is the absolute truth, and it happens, interestingly, every time I go shopping and pay with US dollars.

    Absolutely! Here in Finland I always sing 80's hits when I pay the groceries with, yes, dollars and cents, not euros. Just today when I was at the local store where they sell food and "Final Countdown" cd's I decided to sing "I just died in you arms tonight" between dollars and cents. Good thing there was a comma between them. If it were a period, I'd go bonkers.

  • (cs) in reply to European

    There are lots of reasons not to use the Metric system, the first of which being that there's too many units that no one actually uses. For example, the decimeter. No one actually uses the decimeter. It's there, of course, because it has to be there, but nobody uses it. Common usage is millimeter, centimeter (although I see 0.3cm and the like all the time), the meter, and the kilometer.

    When was the last time you saw something listed in megameters? You just don't--which leads to a lot of confusion on the part of people trying to convert to metric. ("Why are there all these names I have to learn but will never, ever use?")

    And, when you get right down to it, what's so weird about making a unit of length based on any arbitrary thing you happen to like? After all, the original definition of the meter was 1/10,000,000 of the distance from the equator to the north pole through Paris (through Paris!). That's right, ladies and germs, the unit of straight-line measurement was determined as 1/10,000,000 of a particular arc! (Those wacky French!)

    Now it's a bit better defined (distance travelled by light in a perfect vacuum in 1/c seconds), but it's still arbitrary.

    Learning the Imperial system isn't that difficult, either--really little more difficult than learning an alphabet. Since I have training in the sciences, I know both the Imperial and Metric systems--which I believe, under your qualifications, means I have a brain. Maybe more of a brain than you Metric-only goons.

    It could happen.

  • facetious (unregistered)

    //s

  • (cs) in reply to PS
    PS:
    Another post about that Europe place. If they don't speak English then how do you expect them to understand the correct usage of commas and decimal points. I do understand that those Europe people probably need the comma between the dollars and the cents because they probably need a small pause between the dollars and the cents to sing a few lines from "The Final Countdown".

    lol. (joke mode on) oh, yeah. We in Europe so boringly sticked to the IS measuring system, measuring length in meters and kilometers instead of the more fuzzy inches, yards, miles; measuring capacity in litres instead of the unconvertible uk gallons and us gallons... You know leave us a bit of fun in changing your 1.540 ways of measuring things... (/joke mode off)

    no flames please :)

  • ewan (unregistered)

    I think you need to include an explaination of why the code in question is a wtf in each case.

    knowing c# I can tell that the code should have dimensioned maxValue as decimal and then relied on maxValue.toString() to apply the correct culture settings on output (presumably its written to a page at some point.

    But I am often confused by the c and other language ones, so i guess its reasonable that poeple dont get this one.

  • foo (unregistered) in reply to aikii
    aikii:
    That's why every programmer should first learn low-level languages, and exercise himself in manipulating integers, floats, fixed points numbers and strings, converting one type to another in assembly. That's the kind of mistake you make if you have no clue about how variables are stored in memory. So he thought numbers need to be localized before comparisons.

    Joel Polsky regularly writes about that matter. This programmer must be proficient in writing "Shlemiel the painter's algorithms"

    http://www.joelonsoftware.com/articles/fog0000000319.html

    I like Joel's writing, but he gets facts wrong. He says Pascal "fixed" C strings by storing the length, but in fact Pascal predated C by 8 years.

  • Dennis (unregistered) in reply to iceburg
    iceburg:
    I may be missing something, but why are globalization settings set by CurrentThread? Are they worried one thread might be in a different country than another?

    Actually this is common. Consider running a German application on an English operating system. The system locale and the thread locale will not match.

    For extra fun, imagine that the German application is using UI components from the OS. If that UI component chooses its string resources based on the OS locale instead of the thread locale, you'll get a language mismatch. I've had to deal with exactly this issue before.

  • wayne (unregistered) in reply to mrprogguy
    mrprogguy:
    There are lots of reasons not to use the Metric system, the first of which being that there's too many units that no one actually uses. For example, the decimeter. No one actually uses the decimeter. It's there, of course, because it has to be there, but nobody uses it. Common usage is millimeter, centimeter (although I see 0.3cm and the like all the time), the meter, and the kilometer.

    When was the last time you saw something listed in megameters? You just don't--which leads to a lot of confusion on the part of people trying to convert to metric. ("Why are there all these names I have to learn but will never, ever use?")

    And, when you get right down to it, what's so weird about making a unit of length based on any arbitrary thing you happen to like? After all, the original definition of the meter was 1/10,000,000 of the distance from the equator to the north pole through Paris (through Paris!). That's right, ladies and germs, the unit of straight-line measurement was determined as 1/10,000,000 of a particular arc! (Those wacky French!)

    Now it's a bit better defined (distance travelled by light in a perfect vacuum in 1/c seconds), but it's still arbitrary.

    Learning the Imperial system isn't that difficult, either--really little more difficult than learning an alphabet. Since I have training in the sciences, I know both the Imperial and Metric systems--which I believe, under your qualifications, means I have a brain. Maybe more of a brain than you Metric-only goons.

    It could happen.

    It's always fun when someone starts to defend the imperial system.

    You gave exactly no reason against the metric system and you gave exactly no reason for the imperial system.

    The only advantage of the imperial system in countries like the U.S. is that you guys already know it.

  • wayne (unregistered) in reply to mrprogguy
    mrprogguy:
    There are lots of reasons not to use the Metric system, the first of which being that there's too many units that no one actually uses. For example, the decimeter. No one actually uses the decimeter. It's there, of course, because it has to be there, but nobody uses it. Common usage is millimeter, centimeter (although I see 0.3cm and the like all the time), the meter, and the kilometer.

    When was the last time you saw something listed in megameters? You just don't--which leads to a lot of confusion on the part of people trying to convert to metric. ("Why are there all these names I have to learn but will never, ever use?")

    And, when you get right down to it, what's so weird about making a unit of length based on any arbitrary thing you happen to like? After all, the original definition of the meter was 1/10,000,000 of the distance from the equator to the north pole through Paris (through Paris!). That's right, ladies and germs, the unit of straight-line measurement was determined as 1/10,000,000 of a particular arc! (Those wacky French!)

    Now it's a bit better defined (distance travelled by light in a perfect vacuum in 1/c seconds), but it's still arbitrary.

    Learning the Imperial system isn't that difficult, either--really little more difficult than learning an alphabet. Since I have training in the sciences, I know both the Imperial and Metric systems--which I believe, under your qualifications, means I have a brain. Maybe more of a brain than you Metric-only goons.

    It could happen.

    It's always fun when someone starts to defend the imperial system.

    You gave exactly no reason against the metric system and you gave exactly no reason for the imperial system.

    The only advantage of the imperial system in countries like the U.S. is that you guys already know it.

  • Iceman (unregistered) in reply to Youssef
    Youssef:
    Iceman:
    Youssef:
    In Hindi number, the zero is represented as a dot: 1000 = 1... 1000.5 = |...,O (yes, five looks more like an O in Hindi - and one is just a straight line. They're still represented as 1 and 5 in your integer though)

    Nonsense. Hindi 0 does not look like a dot, nor does 5 look like O. http://www.anu.edu.au/asianstudies/hindi/tech/ANU_Hind_layout.png

    Maybe you need to look here: http://en.wikipedia.org/wiki/Arabic_numerals#Evolution_of_symbols

    I should have been more percise - Arabic-Indic numerals in what's used in everyday's life in all 22 Arab countries.

    That being said - you can see clearly in this image http://www.datacal.com/products/arabic-keyboards_l.htm that the dot cannot be used as a separator in Arabic-Indic numerals since it is really the zero number.

    Yes, you should have been more precise. The Wikipedia link clearly shows that Hindi 0 doesn't look like a dot and that Hindi 5 does not look like an O. If you had said Arabic-Indic at the very outset, there would have been no argument from me.

    captcha: poindexter

  • Asd (unregistered) in reply to mkb
    mkb:
    BTW, start mocking other nations when yours get something like a decent history... At least, our forefathers weren't outcasts come from England's jails

    That's Australia.

    There was a similar situation with America too. Deportation and indentured service in America, or hanging were offered as options to convicted criminals

  • Youssef (unregistered) in reply to Iceman
    Iceman:
    Youssef:
    Iceman:
    Youssef:
    In Hindi number, the zero is represented as a dot: 1000 = 1... 1000.5 = |...,O (yes, five looks more like an O in Hindi - and one is just a straight line. They're still represented as 1 and 5 in your integer though)

    Nonsense. Hindi 0 does not look like a dot, nor does 5 look like O. http://www.anu.edu.au/asianstudies/hindi/tech/ANU_Hind_layout.png

    Maybe you need to look here: http://en.wikipedia.org/wiki/Arabic_numerals#Evolution_of_symbols

    I should have been more percise - Arabic-Indic numerals in what's used in everyday's life in all 22 Arab countries.

    That being said - you can see clearly in this image http://www.datacal.com/products/arabic-keyboards_l.htm that the dot cannot be used as a separator in Arabic-Indic numerals since it is really the zero number.

    Yes, you should have been more precise. The Wikipedia link clearly shows that Hindi 0 doesn't look like a dot and that Hindi 5 does not look like an O. If you had said Arabic-Indic at the very outset, there would have been no argument from me.

    captcha: poindexter

    You can blame MS for this problem with percision. In order to display the numberals in Arabic-Indic, you need to choose Hindi numberals in Windows. If you choose Arabic, you get latin numerals - I was pretty much using the same pattern in this discussion.

Leave a comment on “Local Mistakes”

Log In or post as a guest

Replying to comment #120050:

« Return to Article