summaryrefslogtreecommitdiff
path: root/include/rtl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-10-01 12:11:19 +0200
committerEike Rathke <erack@redhat.com>2016-10-01 22:55:57 +0000
commit2135eae2a97c17d89cb47a2074830fd2d7b2226f (patch)
tree6f91d5cdc9ffc0653275b020529848756305b71b /include/rtl
parentec3aabe66bde2c8bdea2c3692ac1c4981c8910a3 (diff)
let approxEqual() not scale too early for large representable integer values
And since this is now too much code for inline move implementation to math.cxx Which again made it necessary to give libreofficekit lokdocview.cxx its own implementation that doesn't even claim to build against sal ... Change-Id: I0f80be9d9172ee20693b9babde715206f2c3d8c1 Reviewed-on: https://gerrit.libreoffice.org/29428 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/math.h8
-rw-r--r--include/rtl/math.hxx14
2 files changed, 11 insertions, 11 deletions
diff --git a/include/rtl/math.h b/include/rtl/math.h
index 41047e139d01..1217e65adb20 100644
--- a/include/rtl/math.h
+++ b/include/rtl/math.h
@@ -422,6 +422,14 @@ SAL_DLLPUBLIC double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THR
*/
SAL_DLLPUBLIC double SAL_CALL rtl_math_approxValue(double fValue) SAL_THROW_EXTERN_C();
+/** Test equality of two values with an accuracy of the magnitude of the
+ given values scaled by 2^-48 (4 bits roundoff stripped).
+
+ @attention
+ approxEqual( value!=0.0, 0.0 ) _never_ yields true.
+ */
+SAL_DLLPUBLIC bool SAL_CALL rtl_math_approxEqual(double a, double b) SAL_THROW_EXTERN_C();
+
/** Returns more accurate e^x-1 for x near 0 than calculating directly.
expm1 is part of the C99 standard, but not provided by some compilers.
diff --git a/include/rtl/math.hxx b/include/rtl/math.hxx
index 642763dfc2d7..fed674fdd210 100644
--- a/include/rtl/math.hxx
+++ b/include/rtl/math.hxx
@@ -239,20 +239,11 @@ inline double acosh(double fValue)
return rtl_math_acosh(fValue);
}
-
-/** Test equality of two values with an accuracy of the magnitude of the
- given values scaled by 2^-48 (4 bits roundoff stripped).
-
- @attention
- approxEqual( value!=0.0, 0.0 ) _never_ yields true.
+/** A wrapper around rtl_math_approxEqual.
*/
inline bool approxEqual(double a, double b)
{
- if ( a == b )
- return true;
- double x = a - b;
- return (x < 0.0 ? -x : x)
- < ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 * 16777216.0)));
+ return rtl_math_approxEqual( a, b );
}
/** Test equality of two values with an accuracy defined by nPrec
@@ -268,6 +259,7 @@ inline bool approxEqual(double a, double b, sal_Int16 nPrec)
return (x < 0.0 ? -x : x)
< ((a < 0.0 ? -a : a) * (1.0 / (pow(static_cast<double>(2.0), nPrec))));
}
+
/** Add two values.
If signs differ and the absolute values are equal according to approxEqual()