summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-12-01 19:08:26 +0100
committerEike Rathke <erack@redhat.com>2020-12-02 11:36:33 +0100
commit1ad0ec4f10270eb44b558e6e8c6261d793fddb2f (patch)
treef31cd82e331ef3782e9ffb563e13c98fbfcdfd6b /sal
parent358f2ce190dcebb185f18bc23953f99f81c3b940 (diff)
Related: tdf#138360 Rounding integers to decimals is futile
Change-Id: Ica25747a26d6c2637c46808d1b73aeeed6e1df37 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107001 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit 49aff144c72a5258cf2ca392a0cfb7a31fb86819) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107017
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/math.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 1d6cb88327f9..10417742b3a2 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -1146,7 +1146,10 @@ double SAL_CALL rtl_math_round(double fValue, int nDecPlaces,
// Rounding to decimals between integer distance precision (gaps) does not
// make sense, do not even try to multiply/divide and introduce inaccuracy.
- if (nDecPlaces >= 0 && fValue >= (static_cast<sal_Int64>(1) << 52))
+ // For same reasons, do not attempt to round integers to decimals.
+ if (nDecPlaces >= 0
+ && (fValue >= (static_cast<sal_Int64>(1) << 52)
+ || isRepresentableInteger(fValue)))
return bSign ? -fValue : fValue;
double fFac = 0;