[erlang-questions] integer-string conversions.

Björn-Egil Dahlberg wallentin.dahlberg@REDACTED
Sat Apr 9 00:54:22 CEST 2011


lists:flatten(io_lib:format("~2.2.0w", [2])) -> "02".

See,
http://www.erlang.org/doc/man/io.html#fwrite-1

for more information.

// Björn-Egil


2011/4/9 Peter W. Morreale <pmorreale@REDACTED>

>
> 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?
>
> THanks,
> -PWM
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110409/3c559aca/attachment.htm>


More information about the erlang-questions mailing list