How do i format a number with digit grouping?
-
I remember in visual basic there was a function for formatting numbers which seperated the number 1763836382 to 1,763,836,382 or 1.763.836.382 depending on the system settings. is there a function that will do that in c++, or is there just a function that will seperate them with a specified character? (i was thinking
sprintf
but couldn't find that specific flag for digit grouping) Thanks in advance. -Rune Svendsen -
I remember in visual basic there was a function for formatting numbers which seperated the number 1763836382 to 1,763,836,382 or 1.763.836.382 depending on the system settings. is there a function that will do that in c++, or is there just a function that will seperate them with a specified character? (i was thinking
sprintf
but couldn't find that specific flag for digit grouping) Thanks in advance. -Rune SvendsenTake a look at the GetNumberFormat in the MSDN. Here's a quote: "The GetNumberFormat function formats a number string as a number string customized for a specified locale." So you can use regular sprintf to format the number as a string, and then format that string to the specified locale. Chris Richardson