summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-09-16 11:59:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-16 20:22:35 +0200
commit3b995a0f54ed6d16b090cb4873418d22faafc139 (patch)
treef1e7b26830eb11053a4485f91b69a5e3bd3c84e9
parentCppunitTest_sw_core_text needs some more RTTI now in UBSan builds (diff)
downloadcore-3b995a0f54ed6d16b090cb4873418d22faafc139.tar.gz
core-3b995a0f54ed6d16b090cb4873418d22faafc139.zip
Revert "speedup rational_FromDouble"
This reverts commit 67d83e40e2c4f3862c50e6abeabfc24a75119fc8. because it causes less accuracy sometimes, eg. see https://gerrit.libreoffice.org/c/core/+/122186 Change-Id: I06eb4921359a8fe6689c6cfd3e2967e25b646fa3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122124 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit f2315daf701847a180a5759039b4951fb4da0653) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122126
-rw-r--r--tools/source/generic/fract.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 57dd4e79c138..1b3c95a6cdda 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -370,8 +370,8 @@ bool operator > ( const Fraction& rVal1, const Fraction& rVal2 )
}
// If dVal > LONG_MAX or dVal < LONG_MIN, the rational throws a boost::bad_rational.
-// Otherwise, dVal and denominator are multiplied by 8, until one of them
-// is larger than (LONG_MAX / 8).
+// Otherwise, dVal and denominator are multiplied by 10, until one of them
+// is larger than (LONG_MAX / 10).
//
// NOTE: here we use 'sal_Int32' due that only values in sal_Int32 range are valid.
static boost::rational<sal_Int32> rational_FromDouble(double dVal)
@@ -381,11 +381,11 @@ static boost::rational<sal_Int32> rational_FromDouble(double dVal)
std::isnan(dVal) )
throw boost::bad_rational();
- const sal_Int32 nMAX = std::numeric_limits<sal_Int32>::max() / 8;
+ const sal_Int32 nMAX = std::numeric_limits<sal_Int32>::max() / 10;
sal_Int32 nDen = 1;
while ( std::abs( dVal ) < nMAX && nDen < nMAX ) {
- dVal *= 8;
- nDen *= 8;
+ dVal *= 10;
+ nDen *= 10;
}
return boost::rational<sal_Int32>( sal_Int32(dVal), nDen );
}