[erlang-questions] simple question: how to convert integers to string with fixed digits

Matej Kosik kosik@REDACTED
Sat Dec 1 18:57:11 CET 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Håkan Stenholm wrote:
> Matej Kosik wrote:
>
> You can experiment with the io:format(...) (or io_lib:format(...))
> string, this works in you case:
>
> 6> io:format("~2..0w", [2]).
> 02
>
> 10> io:format("~2.16.0B", [255]).
> FF
>

These procedures work fine. Reading the manual I was not able to recognize such possibilities. They
print the term on the terminal in the way I need it.

These parameters also kind be used with

	io_lib:fwrite/2

even though its results, for example in these cases:

	io_lib:fwrite("~2.16.0B", [12]).

is weird

	[["0","C"]]

I would expect:

	["0C"]

Nonetheless the weird returned object seems to behave as the expected string.

Thank you
- --
Matej Kosik
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHUaB3L+CaXfJI/hgRApwQAKC8UYMBaWMeKdFQhlMr9Fq+O2t4QQCg1CPb
cHjy/9B656Xr+FtX935lboE=
=NFxh
-----END PGP SIGNATURE-----



More information about the erlang-questions mailing list