improve ==(int)

This commit is contained in:
Tobias Berger 2021-09-21 11:41:35 +02:00
parent 2e778ff3f4
commit 85e1b0c77e

View file

@ -78,7 +78,8 @@ namespace FractionNS {
double Fraction::toDouble() const { return double(m_numerator) / m_denominator; }
bool Fraction::operator==(const int n) const {
return (double(m_numerator) / double(m_denominator)) == n;
return m_denominator == 1
&& m_numerator == n;
}
bool Fraction::operator==(const float n) const {
return (float(m_numerator) / float(m_denominator)) == n;