From: VMware, Inc <> Date: Thu, 24 Feb 2011 21:28:10 +0000 (-0800) Subject: lib/lock: fix stdDev X-Git-Tag: 2011.02.23-368700~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ac06e68b6c5c69f896da28ed39bed6ee84ccf175;p=thirdparty%2Fopen-vm-tools.git lib/lock: fix stdDev The standard deviation computation is incorrect when then there are multiple observations and they are all 0. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/lock/ulStats.c b/open-vm-tools/lib/lock/ulStats.c index 98963ad4f..2bc66e108 100644 --- a/open-vm-tools/lib/lock/ulStats.c +++ b/open-vm-tools/lib/lock/ulStats.c @@ -538,6 +538,10 @@ MXUserSqrt(double x) // IN: hack until next round when FP goes away double xn; double xn1 = x; + if (x == 0.0) { + return 0.0; + } + do { xn = xn1; xn1 = (xn + x/xn) / 2.0;