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 00:27:30 +0100
commit49aff144c72a5258cf2ca392a0cfb7a31fb86819 (patch)
tree9f9db993150f964704f27ad51aac7a3b18b404af /sal
parent462c79c9e9c9163bd9b7ce48e19c9c2f5d49333c (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
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;