I have binary strings in the form of either:
<<"5.7778345">>
or
<<"444555">> >
<<"444555">>
Intermediate conversion to list is unnecessary since Erlang/OTP R16B:
-spec binary_to_number(binary()) -> float() | integer(). binary_to_number(B) -> try binary_to_float(B) catch error:badarg -> binary_to_integer(B) end.