Skip to content

Commit

Permalink
fixed prf:human bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mats cronqvist committed Jan 11, 2011
1 parent 5a35bfa commit 8766db8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/prf.erl
Expand Up @@ -53,19 +53,20 @@ log(ProcInfo,List) ->

%%make ints human readable
human(X) when not is_number(X) -> X;
human(I) when I =< 0 -> I;
human(I) ->
human(I) when I < 0 -> "-"++human(-I);
human(I) when 0 < I ->
case math:log10(I) of
M when 15=<M -> human(M-15,"P");
M when 12=<M -> human(M-12,"T");
M when 9=<M -> human(M-9,"G");
M when 6=<M -> human(M-6,"M");
M when 3=<M -> human(M-3,"k");
_ -> flat("~w",[I])
end.
end;
human(_) -> "0".

human(E,M) ->
flat("~.1f~s",[math:pow(10,E),M]).

flat(Format,Args) ->
flat(Format,Args) ->
lists:flatten(io_lib:fwrite(Format,Args)).

0 comments on commit 8766db8

Please sign in to comment.