diff options
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | lib/Smokeping/RRDhelpers.pm | 3 |
2 files changed, 4 insertions, 1 deletions
@@ -1,3 +1,5 @@ +* fixed problem with rounding error in calculating stddev + 2007/9/06 -- released version 2.2.3 * alter ajax grapher mode to use seconds timestamps and not iso dates this prevents timezone problems with the browser -- tobi diff --git a/lib/Smokeping/RRDhelpers.pm b/lib/Smokeping/RRDhelpers.pm index 3f4fa5b..e491a5c 100644 --- a/lib/Smokeping/RRDhelpers.pm +++ b/lib/Smokeping/RRDhelpers.pm @@ -52,7 +52,8 @@ sub get_stddev{ } } return undef unless $cnt; - return sqrt( 1.0 / $cnt * ( $sqsum - $sum**2 / $cnt )) + my $sqdev = 1.0 / $cnt * ( $sqsum - $sum**2 / $cnt ); + return $sqdev < 0.0 ? 0.0 : sqrt($sqdev); } |