[erlang-questions] Bug in erlang?

Mike Oxford moxford@REDACTED
Sat Jul 13 06:33:05 CEST 2013


Maybe idiosyncrasy?

>From the command-line, everything is expected and looks correct...

list_to_float(lists:flatten(io_lib:format("~.2f",[3.4]))).
3.4
list_to_float(lists:flatten(io_lib:format("~.2f",[1.000000e+00]))).
1.00

But inside of a .beam'd module...
                                            erlang:display(V),

erlang:display(lists:flatten(io_lib:format("~.2f",[V]))),
                                            V2 =
list_to_float(lists:flatten(io_lib:format("~.2f",[V]))),
                                            erlang:display(V2)

gives...

1.000000e+00
"1.00"
1.000000e+00

So the interesting part is that it (list_to_float) works as expected
in the shell, but not in a compiled .beam file.

Note that float_to_list/2 will take options, but there is not
list_to_float/2 with options to specify format.

Curious.

-mox



More information about the erlang-questions mailing list