On Tuesday, September 14, 2010 13:00:22 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. I can write a little function to > do this, but doesn't format already has this builtin? I searched for > vsprintf(), printf, etc., and they all have a glyphic way of saying > things. > > I know that I can use, > > real amt = 2342.23; > char[] z = format("%.2f",amt); > > but, I want to do the $2,342.23. > > Can anyone help a poor man? :-) > > thanks, > > josé
format() should work with the same types of parameters that printf() works with ( http://www.cplusplus.com/reference/clibrary/cstdio/printf/ ). That should allow you to set the precision that you want, but I don't believe that it does anything with commas. If you want that, I believe that you're going to have to code it yourself. - Jonathan M Davis