summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-11-17 16:25:55 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-11-17 19:28:05 +0100
commitb254ecc2bbc716343fccf303f58dfb034b487bca (patch)
tree73f61fac1c937e2fa4b59e742920cfaa9452861f /sal
parentf394e2519c99cd1514c859cda67b1c09e68e6c19 (diff)
Use C++17 hex-exponent floating point literals
... instead of some calculated/hardcoded decimal literals. The new syntax represents the power of 2 exponent directly. Change-Id: I826bda6e06ec77f0706bb48abe2934f7289fddc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125359 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/math.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 6acf3a943fb2..bec83c380b32 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -1130,7 +1130,7 @@ double SAL_CALL rtl_math_round(double fValue, int nDecPlaces,
// make sense, do not even try to multiply/divide and introduce inaccuracy.
// For same reasons, do not attempt to round integers to decimals.
if (nDecPlaces >= 0
- && (fValue >= (static_cast<sal_Int64>(1) << 52)
+ && (fValue >= 0x1p52
|| isRepresentableInteger(fValue)))
return fOrigValue;
@@ -1181,7 +1181,7 @@ double SAL_CALL rtl_math_round(double fValue, int nDecPlaces,
// Round only if not already in distance precision gaps of integers, where
// for [2^52,2^53) adding 0.5 would even yield the next representable
// integer.
- if (fValue < (static_cast<sal_Int64>(1) << 52))
+ if (fValue < 0x1p52)
{
switch ( eMode )
{
@@ -1276,7 +1276,7 @@ double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C()
double SAL_CALL rtl_math_approxValue( double fValue ) SAL_THROW_EXTERN_C()
{
- const double fBigInt = 2199023255552.0; // 2^41 -> only 11 bits left for fractional part, fine as decimal
+ const double fBigInt = 0x1p41; // 2^41 -> only 11 bits left for fractional part, fine as decimal
if (fValue == 0.0 || fValue == HUGE_VAL || !std::isfinite( fValue) || fValue > fBigInt)
{
// We don't handle these conditions. Bail out.
@@ -1325,8 +1325,8 @@ double SAL_CALL rtl_math_approxValue( double fValue ) SAL_THROW_EXTERN_C()
bool SAL_CALL rtl_math_approxEqual(double a, double b) SAL_THROW_EXTERN_C()
{
- static const double e48 = 1.0 / (16777216.0 * 16777216.0);
- static const double e44 = e48 * 16.0;
+ static const double e48 = 0x1p-48;
+ static const double e44 = 0x1p-44;
if (a == b)
return true;