Hello--I am trying to format numbers so they appear 111,111,111,111 (with
the commas at the
thousands place. Is there a defined function that will format the numbers
with the commas?
thanks in advance
Re: number format
"cal" <firstname.lastname@example.org> wrote:
>Hello--I am trying to format numbers so they appear 111,111,111,111 (with
>the commas at the
>thousands place. Is there a defined function that will format the numbers
>with the commas?
>thanks in advance
I don't know of one in the standard off the top of my head, but this should
work (or something close to it, since I just typed it out).
string& outResult ,
long inSource )
outResult = "" ; // For safety
char aBuffer [ 255 + 1 ] ;
char* aIndex = aBuffer ;
int i = 0 ;
while ( inSource )
*aIndex = inSource % 10 + '0' ;
inSource /= 10 ;
if ( i % 2 )
*aIndex = ',' ;
while ( aIndex-- != aBuffer )
outResult += *aIndex ;
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL