Use io_lib:format/2 instead of float_to_list/1 to display floats
Erlang's list_to_float/1 function will use scientific notation and add additional less significant digits to the resulting string due to the internal floating point representation. io_lib:format/2 rounds the values to better match what the user normally expects. e.g. > float_to_list(0.66). "6.60000000000000031086e-01" > io_lib:format("~w", [0.66]). ["0.66"]
This commit is contained in:
parent
8fd9eae57d
commit
86058fbdca
@ -698,7 +698,7 @@ format_usage_line(_MaxOptionLength, _MaxLineLength, {_OptionLength, OptionText,
|
|||||||
|
|
||||||
|
|
||||||
%% @doc Wrap a text line converting it into several text lines so that the
|
%% @doc Wrap a text line converting it into several text lines so that the
|
||||||
%% length of each one of them is never over HelpLength characters.
|
%% length of each one of them is never over Length characters.
|
||||||
-spec wrap_text_line(Length :: non_neg_integer(), Text :: string()) -> [string()].
|
-spec wrap_text_line(Length :: non_neg_integer(), Text :: string()) -> [string()].
|
||||||
wrap_text_line(Length, Text) ->
|
wrap_text_line(Length, Text) ->
|
||||||
wrap_text_line(Length, Text, [], 0, []).
|
wrap_text_line(Length, Text, [], 0, []).
|
||||||
@ -730,7 +730,7 @@ default_arg_value_to_string(Value) when is_binary(Value) ->
|
|||||||
default_arg_value_to_string(Value) when is_integer(Value) ->
|
default_arg_value_to_string(Value) when is_integer(Value) ->
|
||||||
integer_to_list(Value);
|
integer_to_list(Value);
|
||||||
default_arg_value_to_string(Value) when is_float(Value) ->
|
default_arg_value_to_string(Value) when is_float(Value) ->
|
||||||
float_to_list(Value);
|
lists:flatten(io_lib:format("~w", [Value]));
|
||||||
default_arg_value_to_string(Value) ->
|
default_arg_value_to_string(Value) ->
|
||||||
Value.
|
Value.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user