Special case Approx(inf) to better follow user expectations

This commit is contained in:
Martin Hořeňovský 2019-10-04 13:23:14 +02:00
parent 815f99541d
commit 02ee130bd0
No known key found for this signature in database
GPG key ID: DE48307B8B0D381A
7 changed files with 12 additions and 77 deletions

View file

@ -52,7 +52,8 @@ namespace Detail {
bool Approx::equalityComparisonImpl(const double other) const {
// First try with fixed margin, then compute margin based on epsilon, scale and Approx's value
// Thanks to Richard Harris for his help refining the scaled margin value
return marginComparison(m_value, other, m_margin) || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(m_value)));
return marginComparison(m_value, other, m_margin)
|| marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(std::isinf(m_value)? 0 : m_value)));
}
void Approx::setMargin(double newMargin) {