[erlang-questions] integer-string conversions.
Mihai Balea
mihai@REDACTED
Sat Apr 9 00:55:19 CEST 2011
On Apr 8, 2011, at 6:44 PM, Peter W. Morreale wrote:
>
> I bet this has come up a lot, however I can't find anything on the web
> that is appropriate... (Nor am I seeing it in the erlang doc...)
>
> Need to convert an integer to a string, with a field width and
> precision, such that:
>
> 2 --> "02"
>
> ie: right-justified and padded with a leading zeros, depending upon
> field width.
>
> How do I do this?
2> io:format("~3..0B\n", [2]).
002
ok
3>
Be careful though:
3> io:format("~3..0B\n", [2345]).
***
ok
4>
Hope this helps
Mihai
More information about the erlang-questions
mailing list