Commit 9e842572 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Have our fuzzy compare depend on std::numeric_limits::epsilon

parent 0a150e8e
......@@ -131,3 +131,13 @@ void Cn::setValue(std::complex<double> v)
m_value = v.real();
}
}
constexpr bool ourFuzzyCompare(qreal a, qreal b)
{
return qAbs(a - b) < std::numeric_limits<double>::epsilon()*2;
}
bool Cn::operator==(const Analitza::Cn& d) const{
return ourFuzzyCompare(m_value, d.m_value) && ourFuzzyCompare(m_imaginaryPart, d.m_imaginaryPart);
}
......@@ -119,8 +119,7 @@ class ANALITZA_EXPORT Cn : public Object
/**
* @returns whether @p d is equal than this object.
*/
bool operator==(const Cn& d) const { return qFuzzyCompare(m_value, d.m_value)
&& qFuzzyCompare(m_imaginaryPart, d.m_imaginaryPart); }
bool operator==(const Cn& d) const;
/**
* @returns whether @p d is less than this object.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment