tdf#129606: limit precision in ScTable::FillAnalyse
... to 16th significant digit of least precise argument. This follows
the practice to only consider 16 significant digits of user-provided
values.
Change-Id: Ic44fff82396f4f383c96343f9b2f7d35ccce9070
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85795
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index c79e81a..5aab834a 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -202,8 +202,11 @@
// We now have two subtractions with a similar but not equal error. Obtain
// the exponent of the error magnitude and round accordingly.
const double e = fabs(d - c);
const double fExp = floor( log10( e));
return rtl::math::round( c, -static_cast<int>(fExp)-1);
const int nExp = static_cast<int>(floor(log10(e))) + 1;
// tdf#129606: Limit precision to the 16th significant digit of the least precise argument.
// Cf. mnMaxGeneralPrecision in sc/source/core/data/column3.cxx.
const int nExpArg = static_cast<int>(floor(log10(std::max(aa, ab)))) - 15;
return rtl::math::round(c, -std::max(nExp, nExpArg));
}
}