summaryrefslogtreecommitdiffstats
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
parentremove one more wrong IsDataFiltered call (diff)
downloadcore-cc94996d96ea8d8e3d136af66846707f9b838bbf.tar.gz
core-cc94996d96ea8d8e3d136af66846707f9b838bbf.zip
autofill increment needs a bit more tolerance, fdo#37424
-rw-r--r--sal/inc/rtl/math.hxx13
-rw-r--r--sc/source/core/data/table4.cxx4
2 files changed, 15 insertions, 2 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()
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index a632cf83bd7a..d15a74e85f0a 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -324,7 +324,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
{
nVal2 = ((ScValueCell*)pCell)->GetValue();
double nDiff = nVal2 - nVal1;
- if ( !::rtl::math::approxEqual( nDiff, rInc ) )
+ if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) )
bVal = false;
nVal1 = nVal2;
}
@@ -395,7 +395,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
if ( nFlag1 == nFlag2 )
{
double nDiff = (double)nVal2 - (double)nVal1;
- if ( !::rtl::math::approxEqual( nDiff, rInc ) )
+ if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) )
bVal = false;
nVal1 = nVal2;
}