summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping/RRDhelpers.pm
diff options
context:
space:
mode:
authorTobi Oetiker <tobi@oetiker.ch>2007-09-11 08:12:01 +0200
committerTobi Oetiker <tobi@oetiker.ch>2007-09-11 08:12:01 +0200
commit3586889c03cae00263de98129b1662e9abc7b14a (patch)
tree4fd7ee65bf78c5b254b4037bca73a2dfb64c1098 /lib/Smokeping/RRDhelpers.pm
parentfa5abd5d25b193c47400f116c852c0a0b176322a (diff)
downloadsmokeping-3586889c03cae00263de98129b1662e9abc7b14a.tar.gz
smokeping-3586889c03cae00263de98129b1662e9abc7b14a.tar.xz
rounding error fix for sqrt
Diffstat (limited to 'lib/Smokeping/RRDhelpers.pm')
-rw-r--r--lib/Smokeping/RRDhelpers.pm3
1 files changed, 2 insertions, 1 deletions
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);
}