Logo

Programming-Idioms

History of Idiom 156 > diff from v13 to v14

Edit summary for version 14 by tkoenig:
New Fortran implementation by user [tkoenig]

Version 13

2019-09-28, 09:13:10

Version 14

2019-09-28, 22:44:15

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
Code
write (unit=s,fmt='(I0.3)') i
Comments bubble
This assumes that s is long enough.