float_to_list vs io:format ~w
Viktor Söderqvist <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <[email protected]> |
Hi!
Apparently, float_to_binary/1 and float_to_list/1 return a different
textual representation than io:format("~w", [Float]) and the shell.
Eshell V11.1.8 (abort with ^G)
1> float_to_list(10.2).
"1.01999999999999992895e+01"
2> 1.01999999999999992895e+01.
10.2
3> io:format("~w~n", [10.2]).
10.2
ok
4> 1.01999999999999992895e+01 =:= 10.2.
true
Apparently, both are correct textual representations of the same
floating point value. Why don't they use the same algorithm?
Viktor