approxEqual: check isFinite()
Necessary as all comparisons involving a Nan evaluate to false and the assert() in isRepresentableInteger() was hit by crash test documents where approxEqual() was called with a least one Nan. Change-Id: I9e8f41c36c0cf14cabf47c3df773c601d32682d6
This commit is contained in:
@@ -1095,6 +1095,8 @@ bool SAL_CALL rtl_math_approxEqual(double a, double b) SAL_THROW_EXTERN_C()
|
|||||||
if (a == 0.0 || b == 0.0)
|
if (a == 0.0 || b == 0.0)
|
||||||
return false;
|
return false;
|
||||||
const double d = fabs(a - b);
|
const double d = fabs(a - b);
|
||||||
|
if (!rtl::math::isFinite(d))
|
||||||
|
return false; // Nan or Inf involved
|
||||||
if (d > ((a = fabs(a)) * e44) || d > ((b = fabs(b)) * e44))
|
if (d > ((a = fabs(a)) * e44) || d > ((b = fabs(b)) * e44))
|
||||||
return false;
|
return false;
|
||||||
if (isRepresentableInteger(d) && isRepresentableInteger(a) && isRepresentableInteger(b))
|
if (isRepresentableInteger(d) && isRepresentableInteger(a) && isRepresentableInteger(b))
|
||||||
|
Reference in New Issue
Block a user