Merge pull request #14 from boundary/drop_negatives

negatives, dont math:log/1 'em
diff --git a/src/bear.erl b/src/bear.erl
index d46aa8a..3feb0bc 100644
--- a/src/bear.erl
+++ b/src/bear.erl
@@ -373,6 +373,8 @@
     1;
 math_log(0.0) ->
     1.0;
+math_log(X) when X < 0 ->
+    0; % it's not possible to take a log of a negative number, return 0
 math_log(X) ->
     math:log(X).
 
diff --git a/test/bear_test.erl b/test/bear_test.erl
index fc37c6b..5b2b4e1 100644
--- a/test/bear_test.erl
+++ b/test/bear_test.erl
@@ -244,6 +244,16 @@
     Stats = bear:get_statistics(bear:test_values()),
     match_values2(Stats).
 
+negative_test() ->
+    %% make sure things don't blow up with a negative value
+    Values = [1,-1,-2,3,3,4,5,6,7],
+    [{min, -2}] = bear:get_statistics_subset(Values, [min]).
+
+negative2_test() ->
+    %% make sure things don't blow up with a negative value
+    Values = [-1,-1,-2,-2,-3,-5,-6,-10],
+    [{min, -10}] = bear:get_statistics_subset(Values, [min]).
+
 match_values([H|T]) ->
     Res = bear:get_statistics_subset(bear:test_values(), [mk_item(H)]),
     Res = [H],