summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-12-17 22:02:48 +0100
committerEike Rathke <erack@redhat.com>2020-12-18 03:17:03 +0100
commita10c33fdbe980effc3a14e773d1b94a14be7d428 (patch)
treef8a8302df5b09c6bcfd37838552b22909ef17de8 /sal
parentcb22636a56b35d4e118446cc3c9fe606db6f46b0 (diff)
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 <erack@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/math.cxx7
1 files changed, 4 insertions, 3 deletions
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