Formatted Output: Exact number of Decimal Places

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 16 20:12:41 PDT 2016


On 05/16/2016 01:24 PM, Q. Schroll wrote:
> Lets say I want to print a table with floats. How can it be formatted
> like that:
> |  2.4   |
> | 12.2   |
> |  8.131 |
> | 17.44  |
> Also acceptable is
> |  2.400 |
> | 12.200 |
> |  8.131 |
> | 17.440 |
> but not
> | 02.4   |
> | 12.2   |
> | 08.131 |
> | 17.44  |
> or any other solutions with leading zeros.

Also try "%.3g".

Ali



More information about the Digitalmars-d-learn mailing list