From 49aff144c72a5258cf2ca392a0cfb7a31fb86819 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Tue, 1 Dec 2020 19:08:26 +0100 Subject: 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 Tested-by: Jenkins --- sal/rtl/math.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sal') 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(1) << 52)) + // For same reasons, do not attempt to round integers to decimals. + if (nDecPlaces >= 0 + && (fValue >= (static_cast(1) << 52) + || isRepresentableInteger(fValue))) return bSign ? -fValue : fValue; double fFac = 0; -- cgit