Skip to content

Commit

Permalink
to_list, to_atom, and to_binary support floats using mochinum:digits
Browse files Browse the repository at this point in the history
  • Loading branch information
choptastic committed Jun 10, 2011
1 parent f392800 commit cafbb78
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/wf_convert.erl
Expand Up @@ -32,16 +32,19 @@ to_list(A) -> inner_to_list(A).
inner_to_list(A) when is_atom(A) -> atom_to_list(A);
inner_to_list(B) when is_binary(B) -> binary_to_list(B);
inner_to_list(I) when is_integer(I) -> integer_to_list(I);
inner_to_list(F) when is_float(F) -> mochinum:digits(F);
inner_to_list(L) when is_list(L) -> L.

to_atom(A) when is_atom(A) -> A;
to_atom(B) when is_binary(B) -> to_atom(binary_to_list(B));
to_atom(I) when is_integer(I) -> to_atom(integer_to_list(I));
to_atom(F) when is_float(F) -> to_atom(mochinum:digits(F));
to_atom(L) when is_list(L) -> list_to_atom(binary_to_list(list_to_binary(L))).

to_binary(A) when is_atom(A) -> to_binary(atom_to_list(A));
to_binary(B) when is_binary(B) -> B;
to_binary(I) when is_integer(I) -> to_binary(integer_to_list(I));
to_binary(F) when is_float(F) -> to_binary(mochinum:digits(F));
to_binary(L) when is_list(L) -> list_to_binary(L).

to_integer(A) when is_atom(A) -> to_integer(atom_to_list(A));
Expand Down

0 comments on commit cafbb78

Please sign in to comment.