Changed the comparison of double values

This commit is contained in:
Kirill Polyakov
2023-10-26 19:02:23 +03:00
parent 6c0060adbd
commit 82c469a0a6
9 changed files with 30 additions and 13 deletions

View File

@ -174,7 +174,7 @@ namespace NSCSS
bool CDigit::Zero() const
{
return 0. == m_oValue;
return (std::abs(m_oValue) <= DBL_EPSILON);
}
void CDigit::Clear()
@ -241,6 +241,16 @@ namespace NSCSS
return m_enUnitMeasure;
}
bool CDigit::operator==(const double &oValue) const
{
return (std::abs(oValue - m_oValue) <= DBL_EPSILON);
}
bool CDigit::operator==(const CDigit &oDigit) const
{
return (std::abs(oDigit.m_oValue - m_oValue) <= DBL_EPSILON);
}
CDigit CDigit::operator+(const CDigit &oDigit) const
{
CDigit oTemp;

View File

@ -87,7 +87,7 @@ namespace NSCSS
return *this;
}
bool operator==(const CValue& oValue) const
bool operator==(const CValue& oValue) const
{
return m_oValue == oValue.m_oValue;
}
@ -141,6 +141,9 @@ namespace NSCSS
UnitMeasure GetUnitMeasure() const;
bool operator==(const double& oValue) const;
bool operator==(const CDigit& oDigit) const;
CDigit operator+(const CDigit& oDigit) const;
CDigit operator-(const CDigit& oDigit) const;
CDigit operator*(const CDigit& oDigit) const;