summaryrefslogtreecommitdiff
path: root/sal/qa/inc/valueequal.hxx
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-01-28 20:57:40 +0100
committerMichael Stahl <mstahl@redhat.com>2012-01-28 20:57:40 +0100
commit2716f7dce26f16a2b677c178aa7d01cea096ae47 (patch)
tree9e9f67205cd5b72f1031721273e1534a3a1e5b0f /sal/qa/inc/valueequal.hxx
parent10ac9e750447fd57e3cef7993b0ad6c6538d6269 (diff)
replace obsolete "master" branch with README that points at new repoHEADmaster-deletedmaster
Diffstat (limited to 'sal/qa/inc/valueequal.hxx')
-rw-r--r--sal/qa/inc/valueequal.hxx136
1 files changed, 0 insertions, 136 deletions
diff --git a/sal/qa/inc/valueequal.hxx b/sal/qa/inc/valueequal.hxx
deleted file mode 100644
index 782362a3f..000000000
--- a/sal/qa/inc/valueequal.hxx
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-#include <math.h>
-
-#define PREC_float 1
-#define PREC_double 2
-#define PREC_long_double 3
-
-template<class T>
-bool is_equal(T x, T y, sal_Int16 _nPrec)
-{
- // due to the fact that this check looks only if both values are equal
- // we only need to look on one value
-
- // 14 digits will announce the checkPrecisionSize
-
- sal_Int32 nPRECISION;
- switch(_nPrec)
- {
- case PREC_float:
- nPRECISION = 6;
- break;
- case PREC_double:
- nPRECISION = 14;
- break;
- case PREC_long_double:
- nPRECISION = 20;
- break;
- default:
- nPRECISION = 2;
- }
-
- if (x < 0)
- {
- x = -x;
- }
- if (y < 0)
- {
- y = -y;
- }
-
- // LLA: due to a bug in printf with '%f' and long double within linux environment
- // we have to use %lf instead.
-
- if (_nPrec != PREC_long_double)
- {
- printf("double equal: %.20f\n", x);
- printf(" %.20f\n", y);
- }
- //here nPrecOfN is the number after dot
- sal_Int32 nBeforeDot = sal_Int32( log10(x) );
- if ( nBeforeDot < 0)
- {
- nBeforeDot = 0;
- }
- //printf("nPRECISION is %d\n", nPRECISION);
- sal_Int32 nPrecOfN = -nPRECISION + nBeforeDot;
-
- if (_nPrec != PREC_long_double)
- printf("nPrecOfN is %d\n", nPrecOfN);
-
- long double nPrec = pow(0.1, -nPrecOfN);
-
- if (_nPrec != PREC_long_double)
- printf(" prec: %.20f\n", nPrec);
-
- long double nDelta = fabs( x - y ) ;
-
- if (_nPrec != PREC_long_double)
- {
- printf(" delta: %.20f\n", nDelta);
- printf(" nPrec: %.20f\n", nPrec);
- printf("delta must be less or equal to prec!\n\n");
- }
-
- if (nDelta > nPrec)
- {
- // printf("values are not equal! ndelta:%.20f\n", nDelta);
- return false;
- }
- // else
- // {
- // printf("values are equal. ndelta:%.20f\n", nDelta);
- return true;
- // }
-}
-
-// LLA: bool is_float_equal(float x, float y)
-// LLA: {
-// LLA: // due to the fact that this check looks only if both values are equal
-// LLA: // we only need to look on one value
-// LLA:
-// LLA: // 6 digits will announce the checkPrecisionSize
-// LLA:
-// LLA: const sal_Int32 nPRECISION = 6;
-// LLA: if (x < 0)
-// LLA: {
-// LLA: x = -x;
-// LLA: }
-// LLA: if (y < 0)
-// LLA: {
-// LLA: y = -y;
-// LLA: }
-// LLA:
-// LLA: printf("double equal: %.20f\n# %.20f\n", x, y);
-// LLA: sal_Int32 nPrecOfN = -nPRECISION + sal_Int32( log10(x) );
-// LLA:
-// LLA: printf("prec: %d\n", nPrecOfN);
-// LLA: double nPrec = pow(10, nPrecOfN) * 1;
-// LLA:
-// LLA: printf(" prec: %.20f\n", nPrec);
-// LLA:
-// LLA: double nDelta = fabs( x - y );
-// LLA: printf(" delta: %.20f\n\n", nDelta);
-// LLA:
-// LLA: if (nDelta > nPrec)
-// LLA: {
-// LLA: // printf("values are not equal! ndelta:%.20f\n", nDelta);
-// LLA: return false;
-// LLA: }
-// LLA: // else
-// LLA: // {
-// LLA: // printf("values are equal. ndelta:%.20f\n", nDelta);
-// LLA: return true;
-// LLA: // }
-// LLA: }
-
-bool is_float_equal(float x, float y)
-{
- return is_equal<float>(x, y, PREC_float);
-}
-bool is_double_equal(double x, double y)
-{
- return is_equal<double>(x, y, PREC_double);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */