Logo

Programming-Idioms

History of Idiom 156 > diff from v6 to v7

Edit summary for version 7 by Bzzzz:
New D implementation by user [Bzzzz]

Version 6

2017-04-29, 06:54:55

Version 7

2017-07-26, 00:19:43

Idiom #156 Format integer with zero-padding

Assign to string s the value of integer i in 3 decimal digits. Pad with zeros if i < 100. Keep all digits if i1000.

Idiom #156 Format integer with zero-padding

Assign to string s the value of integer i in 3 decimal digits. Pad with zeros if i < 100. Keep all digits if i1000.

Extra Keywords
pad leading fixed width
Extra Keywords
pad leading fixed width
Imports
import std.format : format;
Code
string s = format("%03d", i);