summaryrefslogtreecommitdiff
path: root/qadevOOo/runner
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-11-04 21:42:51 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-11-04 21:42:51 +0100
commit177183f692f42f6a0cf5ee66f1b7e1c31a616140 (patch)
treea53ffc782063b39e5f4d6c77944c70a172fb228f /qadevOOo/runner
parent5a29db7a9945c4cd095799451a6c563d5aeeed57 (diff)
Proper fix for coverity#1326893
FindBugs' FE.FE_FLOATING_POINT_EQUALITY is about double value inaccuracies, not about NaN or negative zero (which is the topic of java.lang.Double.equals vs. ==). Reuse existing qa.TestCaseOldAPI.approxEqual method, moved to util.utils. Change-Id: I65f7bb1faf921e1c4035bb96aeff1eaf2cfb3153
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r--qadevOOo/runner/util/utils.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/qadevOOo/runner/util/utils.java b/qadevOOo/runner/util/utils.java
index dc1b63c9c9bf..dc019a4fcbfb 100644
--- a/qadevOOo/runner/util/utils.java
+++ b/qadevOOo/runner/util/utils.java
@@ -874,4 +874,14 @@ public class utils {
* Default short wait time for the Office
*/
public static final int DEFAULT_SHORT_WAIT_MS = 500;
+
+ /// see rtl/math.hxx
+ public static boolean approxEqual( double a, double b )
+ {
+ if( a == b )
+ return true;
+ double x = a - b;
+ return (x < 0.0 ? -x : x)
+ < ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 * 16777216.0)));
+ }
}