[erlang-questions] Fwd: Change in behaviour in 5.9

Vlad Dumitrescu vladdu55@REDACTED
Fri Jan 13 23:21:46 CET 2012


... and to the list ....

Hi!

On Fri, Jan 13, 2012 at 23:15, Bob Cowdery <bob@REDACTED> wrote:
> In erl 5.8.2 I had this:
> S = io_lib:format("~10.6.0f", [Freq]),
> where Freq was a float, say 7.0 and this gave me
> [["00","7.000000"]] so I concat the strings to get what I want which is
> "007.000000"
>
> In 5.9 the code breaks because I get [["00",55,46,48,48,48,48,48,48]].
>
> Neither look right to me but I really don't understand the 5.9 result.
>
> If I do io:format("~10.6.0f", [7.0]). it gives me what I would expect
> "007.000000".
>
> Can someone explain these behaviours please.

io:format returns an iolist. The exact contents may vary, but they
represent the same thing:

3> erlang:iolist_to_binary([["00",55,46,48,48,48,48,48,48]]).
<<"007.000000">>

regards,
Vlad



More information about the erlang-questions mailing list