Skip to content

Commit 54f152d

Browse files
zmstonezhongwencool
authored andcommitted
Fix compile warning on OTP 27
1 parent c4eba84 commit 54f152d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/observer_cli_lib.erl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@ uptime() ->
3535
[?W(?GREEN, Time, 16)].
3636

3737
%% @doc 0.982342 -> 98.23%, 1 -> 100.0%
38-
to_percent(Float) when Float < 0.1 -> [$0, erlang:float_to_list(Float * 100, [{decimals, 2}]), $%];
39-
to_percent(Float) when Float < 1 -> [erlang:float_to_list(Float * 100, [{decimals, 2}]), $%];
40-
to_percent(undefined) -> "******";
41-
to_percent(_) -> "100.0%".
38+
-spec to_percent(term()) -> string().
39+
to_percent(Float) when is_float(Float), Float < 0.1 ->
40+
[$0, erlang:float_to_list(Float * 100, [{decimals, 2}]), $%];
41+
to_percent(Float) when is_float(Float), Float < 1 ->
42+
[erlang:float_to_list(Float * 100, [{decimals, 2}]), $%];
43+
to_percent(undefined) ->
44+
"******";
45+
to_percent(_) ->
46+
"100.0%".
4247

48+
-spec to_list(term()) -> string().
4349
to_list(Atom) when is_atom(Atom) -> atom_to_list(Atom);
4450
to_list(Integer) when is_integer(Integer) -> integer_to_list(Integer);
4551
to_list(Pid) when is_pid(Pid) -> erlang:pid_to_list(Pid);

0 commit comments

Comments
 (0)