[erlang-questions] io:format printing integers prefixed with zero(0)

Michael McDaniel erlangy@REDACTED
Sat May 3 07:22:06 CEST 2008


On Sat, May 03, 2008 at 02:51:33PM +1000, jm wrote:
> Given an integer is there a format which will prefix it with zeros to a 
>   fixed width? eg,
> 
>    3 => 003
>   50 => 050
> 205 => 205
> 
> the equivelant of C's printf("%3.3d", i).
> 
> 
> Jeff.
> _______________________________________________



(del@REDACTED)40> io:fwrite("~3.3.0w ", [1]).
001 ok
(del@REDACTED)41> io:fwrite("~3.3.0w ", [10]).
010 ok
(del@REDACTED)42> io:fwrite("~3.3.0w ", [100]).
100 ok
(del@REDACTED)43> 


 see io docs; file:///usr/local/lib/erlang/lib/stdlib-1.15/doc/html/io.html
 on my system


~Michael



More information about the erlang-questions mailing list