sal/rtl/math.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
New commits: commit a10c33fdbe980effc3a14e773d1b94a14be7d428 Author: Eike Rathke <[email protected]> AuthorDate: Thu Dec 17 22:02:48 2020 +0100 Commit: Eike Rathke <[email protected]> CommitDate: Fri Dec 18 03:17:03 2020 +0100 Replace log2() call with parts.exponent-1023, tdf#138360 follow-up ... to save some cycles as we anyway need only the integer value of the exponent and even exactly this value for the number of possible decimals. Change-Id: I8d462f53cadde6a95d57d1342d8487fbfa001ae9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107928 Tested-by: Jenkins Reviewed-by: Eike Rathke <[email protected]> diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx index 46a3e925b95b..527b508e848c 100644 --- a/sal/rtl/math.cxx +++ b/sal/rtl/math.cxx @@ -1167,9 +1167,10 @@ double SAL_CALL rtl_math_round(double fValue, int nDecPlaces, // Determine how many decimals are representable in the precision. // Anything greater 2^52 and 0.0 was already ruled out above. // Theoretically 0.5, 0.25, 0.125, 0.0625, 0.03125, ... - const double fDec = 52 - log2(fValue) + 1; - if (fDec < nDecPlaces) - nDecPlaces = static_cast<sal_Int32>(fDec); + const sal_math_Double* pd = reinterpret_cast<const sal_math_Double*>(&fValue); + const sal_Int32 nDec = 52 - (pd->parts.exponent - 1023); + if (nDec < nDecPlaces) + nDecPlaces = nDec; } /* TODO: this was without the inverse factor and determining max _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
