3

In many programming languages, the thousands separator (e.g., the "," in the American string "1,000") is called the "grouping separator". Why is this?

Are there any real-world locales that separate written integers on some other boundary? Do people somewhere write numbers like 86,75,30,9 or 8675,309? If so, what are those locales?

This issue came up for me today in Objective-C, when I could not remember the name of the constant to find the string for this separator. I was typing "NSThou" and nothing was autocompleting. I had to go to the docs to be reminded that you get it like this:

NSLocale *loc = [NSLocale currentLocale];
NSString *sep = [loc objectForKey:NSLocaleGroupingSeparator];

However, this is not specific to Objective-C; I recall from my old Java days that it was called the same thing. (Python folks, OTOH, seem to call it the "thousands separator".)

Mason
  • 5,071
  • 4
  • 25
  • 24
  • 1
    Notice that the `NSNumberFormatter` class has two methods for setting the grouping: `setGroupingSize:` and `setSecondaryGroupingSize:`. – rmaddy Mar 08 '13 at 04:47

3 Answers3

6

Wikipedia says:

For example, in various countries (e.g., China, India, and Japan), there have been traditional conventions of grouping by 2 or 4 digits.

ruakh
  • 175,680
  • 26
  • 273
  • 307
Carl Norum
  • 219,201
  • 40
  • 422
  • 469
  • 1
    Or more complicated ways. See e.g. http://en.wikipedia.org/wiki/South_Asian_numbering_system. – ruakh Mar 08 '13 at 04:14
3

Few countries like India and its neighbour uses thousand separator for readability and it is as only last three are grouped in three and rest in two :like

100

1,000

10,000

1,00,000

10,00,000

1,00,00,000

Where as few countries follow grouping of 3 as

100,000

100,000,000


Adding on this, you may get confused few countried uses . and , to represend decimal and thousand seperator, here you can not say what does this value stands for as 10,000 , 10000.00 and 10000,00, Therefore you need to set the localization for number format whenever you ask user to enter a number

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
1

Being a Chinese I think I have a say on this issue.

Chinese numeric system is a bit different than that of English in that we group digits in 4, not 3. This is because we have an additional unit of δΈ‡ ("wan", ten thousand) on top of thousand, hundred, ten and one. So 1000000 in English is a million, but in Chinese is a hundred "wan", thus written as 100,0000 rather than 1,000,000.

Also worth pointing out is that many programming languages have wrong locale implementations on this matter, for example Java's string formatting.

StormSailing
  • 21
  • 2
  • 6