From 77890232a5020dc5caf034da9a2d1bc1392b1a3b Mon Sep 17 00:00:00 2001 From: Tobias Oetiker Date: Thu, 24 Nov 2011 11:25:53 +0100 Subject: fixed off by 1 error --- lib/Smokeping/matchers/Median.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Smokeping/matchers/Median.pm b/lib/Smokeping/matchers/Median.pm index 22a2445..2c721bf 100644 --- a/lib/Smokeping/matchers/Median.pm +++ b/lib/Smokeping/matchers/Median.pm @@ -97,5 +97,6 @@ sub robust_median(@){ my @numbers = sort {$a <=> $b} grep { defined $_ and $_ =~ /\d/ } @_; my $count = scalar @numbers; return 0 if $count == 0; + $count--; # we are 0 based return ($count / 2 == int($count/2)) ? $numbers[$count/2] : ($numbers[$count/2+0.5] + $numbers[$count/2-0.5])/2; } -- cgit v1.2.3-24-g4f1b