How to Humanize Numerical Input|Output

Steven Schveighoffer schveiguy at gmail.com
Mon Sep 9 20:40:28 UTC 2024


On Monday, 9 September 2024 at 20:02:48 UTC, Jabari Zakiya wrote:

> Also for output, I do this:
>
> ```
> writeln("total twins = ", twinscnt, "; last twin = ", last_twin 
> - 1, "+/-1");
> ```
>
> I'd also like to output data as:  123,987 or 123_987

You can use separators using writefln:

```d
writefln("%,d", 123987); // 123,987
writefln("%,?d", '_', 123987); // 123_987
```

See https://dlang.org/phobos/std_format.html

-Steve


More information about the Digitalmars-d-learn mailing list