mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 05:24:02 +00:00
[math] Fix equals() for INF and -INF.
This commit is contained in:
parent
b9ee6f0d51
commit
1bff0ad9e9
@ -160,16 +160,17 @@ struct equals<Type, true>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool const a_inf = boost::math::isinf(a);
|
if (boost::math::isfinite(a) && boost::math::isfinite(b))
|
||||||
bool const b_inf = boost::math::isinf(b);
|
|
||||||
if (a_inf != b_inf)
|
|
||||||
{
|
{
|
||||||
// If a is INF and b is 0, the expression below returns true, but
|
// If a is INF and b is e.g. 0, the expression below returns true
|
||||||
// the values are obviously not equal
|
// but the values are obviously not equal, hence the condition
|
||||||
return false;
|
return abs<Type>::apply(a - b)
|
||||||
|
<= std::numeric_limits<Type>::epsilon() * policy.apply(a, b);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return a == b;
|
||||||
}
|
}
|
||||||
|
|
||||||
return abs<Type>::apply(a - b) <= std::numeric_limits<Type>::epsilon() * policy.apply(a, b);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user