Formatted Output: Exact number of Decimal Places

Marco Leise via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 16 17:26:59 PDT 2016


Am Mon, 16 May 2016 20:24:51 +0000
schrieb Q. Schroll <qs.il.paperinik at gmail.com>:

> 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 |

Use %#6.3f to get the above output.

> but not
> | 02.4   |
> | 12.2   |
> | 08.131 |
> | 17.44  |
> or any other solutions with leading zeros.

-- 
Marco



More information about the Digitalmars-d-learn mailing list