[Libreoffice-commits] core.git: sal/rtl
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 29 14:25:18 UTC 2021
sal/rtl/math.cxx | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
New commits:
commit 0bc7b206c8f6e62313ae2f26211b15cac880125f
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Sep 29 14:23:37 2021 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed Sep 29 16:24:46 2021 +0200
Simplify integer rounding
Change-Id: I09ab406a8b7279801ce79b2f9c0a0011f6db05be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122749
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index feb3a2b1852d..6de4d30383cd 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -356,16 +356,8 @@ void doubleToString(typename T::String ** pResult,
if (nDecPlaces < 0)
{
sal_Int64 nRounding = static_cast< sal_Int64 >(getN10Exp(-nDecPlaces - 1));
- sal_Int64 nTemp = nInt / nRounding;
- int nDigit = nTemp % 10;
- nTemp /= 10;
-
- if (nDigit >= 5)
- ++nTemp;
-
- nTemp *= 10;
- nTemp *= nRounding;
- nInt = nTemp;
+ const sal_Int64 nTemp = (nInt / nRounding + 5) / 10;
+ nInt = nTemp * 10 * nRounding;
nDecPlaces = 0;
}
More information about the Libreoffice-commits
mailing list