5 #define PREC_long_double 3
8 bool is_equal(T x
, T y
, sal_Int16 _nPrec
)
10 // due to the fact that this check looks only if both values are equal
11 // we only need to look on one value
13 // 14 digits will announce the checkPrecisionSize
24 case PREC_long_double
:
40 // LLA: due to a bug in printf with '%f' and long double within linux environment
41 // we have to use %lf instead.
43 if (_nPrec
!= PREC_long_double
)
45 t_print(T_VERBOSE
, "double equal: %.20f\n", x
);
46 t_print(T_VERBOSE
, " %.20f\n", y
);
48 //here nPrecOfN is the number after dot
49 sal_Int32 nBeforeDot
= sal_Int32( log10(x
) );
54 //t_print(T_VERBOSE, "nPRECISION is %d\n", nPRECISION);
55 sal_Int32 nPrecOfN
= -nPRECISION
+ nBeforeDot
;
57 if (_nPrec
!= PREC_long_double
)
58 t_print(T_VERBOSE
, "nPrecOfN is %d\n", nPrecOfN
);
60 long double nPrec
= pow(0.1, -nPrecOfN
);
62 if (_nPrec
!= PREC_long_double
)
63 t_print(T_VERBOSE
, " prec: %.20f\n", nPrec
);
65 long double nDelta
= fabs( x
- y
) ;
67 if (_nPrec
!= PREC_long_double
)
69 t_print(T_VERBOSE
, " delta: %.20f\n", nDelta
);
70 t_print(T_VERBOSE
, " nPrec: %.20f\n", nPrec
);
71 t_print(T_VERBOSE
, "delta must be less or equal to prec!\n\n");
76 // t_print(T_VERBOSE, "values are not equal! ndelta:%.20f\n", nDelta);
81 // t_print(T_VERBOSE, "values are equal. ndelta:%.20f\n", nDelta);
86 // LLA: bool is_float_equal(float x, float y)
88 // LLA: // due to the fact that this check looks only if both values are equal
89 // LLA: // we only need to look on one value
91 // LLA: // 6 digits will announce the checkPrecisionSize
93 // LLA: const sal_Int32 nPRECISION = 6;
103 // LLA: t_print(T_VERBOSE, "double equal: %.20f\n# %.20f\n", x, y);
104 // LLA: sal_Int32 nPrecOfN = -nPRECISION + sal_Int32( log10(x) );
106 // LLA: t_print(T_VERBOSE, "prec: %d\n", nPrecOfN);
107 // LLA: double nPrec = pow(10, nPrecOfN) * 1;
109 // LLA: t_print(T_VERBOSE, " prec: %.20f\n", nPrec);
111 // LLA: double nDelta = fabs( x - y );
112 // LLA: t_print(T_VERBOSE, " delta: %.20f\n\n", nDelta);
114 // LLA: if (nDelta > nPrec)
116 // LLA: // t_print(T_VERBOSE, "values are not equal! ndelta:%.20f\n", nDelta);
117 // LLA: return false;
121 // LLA: // t_print(T_VERBOSE, "values are equal. ndelta:%.20f\n", nDelta);
126 bool is_float_equal(float x
, float y
)
128 return is_equal
<float>(x
, y
, PREC_float
);
130 bool is_double_equal(double x
, double y
)
132 return is_equal
<double>(x
, y
, PREC_double
);