Erlang: How to transform a decimale into a Hex string filled with zeros <p>I would like to transform 42 (Base 10) into 000002A (Base 16) in Erlang...</p> <p>I have found some pointers on the web : </p> <pre><code>io:format("~8..0B~n", [42]) -&gt; 00000042 </code></pre> <p>And</p> <pre><code>io:format("~.16B~n", [42]) -&gt; 2A </code></pre> <p>But I cannot seems to find how to do both at the same time, I have tried : </p> <pre><code>io:format("~8..0.16B~n", [42]) </code></pre> <p>Which seemed to be the logical thing, but it is not, it gives me an error.</p> <p>Thanks.</p>