monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Apr 20 06:58:08 PDT 2014
On Sunday, 20 April 2014 at 12:53:11 UTC, steven kladitis wrote:
> Note sure if you can edit messages once sent.
> On Sunday, 20 April 2014 at 12:50:52 UTC, steven kladitis wrote:
>> How do you format numbers to have things like.
>> Leading $ or , or <CR> with or without leading zeros.
>> for example $56.00
Simply add what you want in the format string. For example:
double d = 56.55;
I don't know of any "built-in" way to do number grouping.
Also, when dealing with monetary amounts, you shouldn't be using
doubles (I'm not saying you are), but some other structure
specifically designed to track cents. Ideally, such a structure
would have built-in "toString" formating.
More information about the Digitalmars-d-learn