Formating decimal numbers with commas (1,000.00)

Steven Schveighoffer schveiguy at yahoo.com
Wed Sep 15 06:02:00 PDT 2010


On Tue, 14 Sep 2010 20:12:53 -0400, Stewart Gordon <smjg_1998 at yahoo.com>  
wrote:

> On 14/09/2010 21:00, jicman wrote:
>>
>> Greetings.
>>
>> I have been trying, for more than an hour, to get information on how
>> to format a number (2342.23) to $2,342.23.
>
> Just wondering, where have you been searching for this information?
>
>> I can write a little function to do this, but doesn't format already
>> has this builtin?
> <snip>
>
> If the documentation
> http://www.digitalmars.com/d/1.0/phobos/std_format.html
> is to go by, there doesn't seem to be any such feature, and a quick look  
> through the code doesn't reveal one either.
>
> But there are many things std.format doesn't do.  I'd imagine that  
> someone's written a more powerful number formatting library module, but  
> I don't know of it.  Maybe that someone'll find this thread and  
> enlighten us.

I believe Tango has an extensive locale library which does this sort of  
thing.

-Steve


More information about the Digitalmars-d-learn mailing list