diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-29 14:23:37 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-29 16:24:46 +0200 |
commit | 0bc7b206c8f6e62313ae2f26211b15cac880125f (patch) | |
tree | fdb0a6963ae7920c6218b3aa3fbfe17c8b7a1853 /sal | |
parent | a92ce1ed68b3f6522db76e8caa7e69cf2f66fc22 (diff) |
Simplify integer rounding
Change-Id: I09ab406a8b7279801ce79b2f9c0a0011f6db05be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122749
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/math.cxx | 12 |
1 files changed, 2 insertions, 10 deletions
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; } |