<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:10pt"><div><div><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; ">How to get an integer 123 as 10-char long string "0000000123" with leading zeroes, i.e. erlang term [48, 48, 48, 48, 48, 48, 48, 49, 50, 51]?</span></div><div><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; "><br></span></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">Following is not what I expect! I tried with both ~B and ~s.</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2"><br></font></div><div><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; ">$ erl</span><br></div><div><font face="'Courier New', courier, monaco, monospace,
sans-serif" size="2">Erlang R14B02 (erts-5.8.3) [source] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2"><br></font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">Eshell V5.8.3 (abort with ^G)</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">1> io_lib:fwrite("~B", [123]).</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">["123"]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">2> io_lib:fwrite("~s", ["123"]).</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">["123"]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">3> io_lib:fwrite("~5B", [123]).</font></div><div><font face="'Courier
New', courier, monaco, monospace, sans-serif" size="2">[[" ",49,50,51]]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">4> io_lib:fwrite("~5..0B", [123]).</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">[["00",49,50,51]]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">5> io_lib:fwrite("~5..0s", ["123"]).</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">[["00",49,50,51]]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">6> io_lib:fwrite("~5.5.0s", ["123"]).</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">[["00",49,50,51]]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">7> io_lib:fwrite("~8..0B", [123]).</font></div><div><font
face="'Courier New', courier, monaco, monospace, sans-serif" size="2">[[[48,"00",48,48],49,50,51]]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">8> io_lib:fwrite("~8..0s", ["123"]).</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">[[[48,"00",48,48],49,50,51]]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">9> io_lib:fwrite("~8.8.0s", ["123"]).</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">[[[48,"00",48,48],49,50,51]]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">10> io_lib:fwrite("~10..0B", [123]).</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">[[[48,"000",48,48,48],49,50,51]]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif"
size="2">11> io_lib:fwrite("~10.10.0s", ["123"]).</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">[[[48,"000",48,48,48],49,50,51]]</font></div><div><font face="'Courier New', courier, monaco, monospace, sans-serif" size="2">12></font></div><div style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 10pt; "><br></div></div></div></body></html>