{"id":31493,"date":"2006-04-18T10:00:11","date_gmt":"2006-04-18T10:00:11","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2006\/04\/18\/how-to-fill-in-that-number-grouping-member-of-numberfmt\/"},"modified":"2006-04-18T10:00:11","modified_gmt":"2006-04-18T10:00:11","slug":"how-to-fill-in-that-number-grouping-member-of-numberfmt","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20060418-11\/?p=31493","title":{"rendered":"How to fill in that number grouping member of NUMBERFMT"},"content":{"rendered":"<p>If you look at the <code>NUMBERFMT<\/code> structure, the way groups are expressed by the <code>Grouping<\/code> member do not match the value returned by <code>LOCALE_SGROUPING<\/code>:<\/p>\n<table>\n<tr>\n<th>LOCALE_<br \/>SGROUPING<\/th>\n<th>Grouping<\/th>\n<th>Sample<\/th>\n<th>Culture<\/th>\n<\/tr>\n<tr>\n<td>3;0<\/td>\n<td>3<\/td>\n<td>1,234,567<\/td>\n<td>United States<\/td>\n<\/tr>\n<tr>\n<td>3;2;0<\/td>\n<td>32<\/td>\n<td>12,34,567<\/td>\n<td>India<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>30<\/td>\n<td>1234,567<\/td>\n<td>(none I know of)<\/td>\n<\/tr>\n<\/table>\n<p> <code>LOCALE_SGROUPING<\/code> expresses grouping as a series of semicolon-separated numbers, each expressing the number of digits in each group (least-significant group first). A trailing zero indicates that the last grouping should be repeated indefinitely. For example, &#8220;3;2;0&#8221; means &#8220;Group the three least significant digits, then in twos until you run out of digits.&#8221; If there is no trailing &#8220;;0&#8221;, then there are no commas past that point. For example, &#8220;3&#8221; means &#8220;Group the three least significant digits, then stop.&#8221;\n The <code>Grouping<\/code> member expresses the grouping rules  differently. Each significant digit represents a group, with the most significant digit representing the least-significant group, with the units digit repeated indefinitely. For example, &#8220;32&#8221; means &#8220;make a group of three digits, then group by twos thereafter.&#8221; To suppress the repetition, multiply by ten.\n In other words, the two systems are basically the same, with the <code>Grouping<\/code> consisting of the <code>LOCALE_SGROUPING<\/code> string with the semicolons removed. Except that the meaning of the trailing zero is reversed, so if <code>LOCALE_SGROUPING<\/code> has a trailing zero, you have to remove it to get the <code>Grouping<\/code>, and if it lacks a trailing zero, then you have to add one to the <code>Grouping<\/code>.\n It&#8217;s kind of strange that the two systems differ, considering that they both came from the same NLS team! It&#8217;s probably a case of parallel evolution, wherein the locale-string folks and the number-formatting folks came up with their respective systems independently.\n Writing code to implement this conversion from <code>LOCALE_SGROUPING<\/code> to <code>Grouping<\/code> shouldn&#8217;t be hard once you understand the algorithm, so I&#8217;ll leave that as an exercise.<\/p>\n<p> Fortunately, in real life you rarely have need to perform this conversion, for you can just pass the desired locale as the first parameter to the <code>GetNumberFormat<\/code> (or even better, <code>LOCALE_USER_DEFAULT<\/code>), pass a <code>NULL<\/code> pointer as the <code>lpNumberFormat<\/code>, and let NLS do all the work. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you look at the NUMBERFMT structure, the way groups are expressed by the Grouping member do not match the value returned by LOCALE_SGROUPING: LOCALE_SGROUPING Grouping Sample Culture 3;0 3 1,234,567 United States 3;2;0 32 12,34,567 India 3 30 1234,567 (none I know of) LOCALE_SGROUPING expresses grouping as a series of semicolon-separated numbers, each expressing [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-31493","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>If you look at the NUMBERFMT structure, the way groups are expressed by the Grouping member do not match the value returned by LOCALE_SGROUPING: LOCALE_SGROUPING Grouping Sample Culture 3;0 3 1,234,567 United States 3;2;0 32 12,34,567 India 3 30 1234,567 (none I know of) LOCALE_SGROUPING expresses grouping as a series of semicolon-separated numbers, each expressing [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/31493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=31493"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/31493\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=31493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=31493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=31493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}