April 17th, 2006

Locale-sensitive number grouping

Most westerners are familiar with the fact that the way numbers are formatted differ between the United States and much of Europe.

Culture Format
United States 1,234,567.89
France 1 234 567,89
Germany 1.234.567,89
Switzerland 1’234’567.89

What people don’t realize is that the grouping is not always in threes. In India, the least significant group consists of three digits, but subsequent groups are in pairs.

India 12,34,567.89

I’ve also seen reports that the first group consists of five digits, followed by pairs:

India 12,34567.89

Meanwhile, Chinese and Japanese traditionally group in fours.

China, Japan 123 4567.89

What does this mean for you? Don’t assume that numbers group in threes, and of course you can’t assume that the grouping separator is the comma and the decimal character is the period. Just use the GetNumberFormat function and let NLS do the work for you.

Next time, a little more about that NUMBERFMT structure.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.