summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-04-14 21:00:19 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-04-15 01:26:02 +0200
commitcc94996d96ea8d8e3d136af66846707f9b838bbf (patch)
treebd72af3df4fae547e8dd9908319203360f96a8ed /sal
parentbc16be3e1ed9257b8adc68390de5dc11da100b56 (diff)
autofill increment needs a bit more tolerance, fdo#37424
Diffstat (limited to 'sal')
-rw-r--r--sal/inc/rtl/math.hxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/sal/inc/rtl/math.hxx b/sal/inc/rtl/math.hxx
index 2018308f9c6c..8f4991a378d0 100644
--- a/sal/inc/rtl/math.hxx
+++ b/sal/inc/rtl/math.hxx
@@ -263,6 +263,19 @@ inline bool approxEqual(double a, double b)
< ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 * 16777216.0)));
}
+/** Test equality of two values with an accuracy defined by nPrec
+
+ @attention
+ approxEqual( value!=0.0, 0.0 ) _never_ yields true.
+ */
+inline bool approxEqual(double a, double b, sal_Int16 nPrec)
+{
+ if ( a == b )
+ return true;
+ double x = a - b;
+ return (x < 0.0 ? -x : x)
+ < ((a < 0.0 ? -a : a) * (1.0 / (pow(2, nPrec))));
+}
/** Add two values.
If signs differ and the absolute values are equal according to approxEqual()