Permalink
Browse files

fixed prf:human bug

  • Loading branch information...
1 parent 5a35bfa commit 8766db8eca133ebe7ae0a9de47451ac0b7b058c1 mats cronqvist committed Jan 11, 2011
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/prf.erl
View
@@ -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.