improve ==(int)
This commit is contained in:
parent
2e778ff3f4
commit
85e1b0c77e
1 changed files with 2 additions and 1 deletions
|
@ -78,7 +78,8 @@ namespace FractionNS {
|
||||||
double Fraction::toDouble() const { return double(m_numerator) / m_denominator; }
|
double Fraction::toDouble() const { return double(m_numerator) / m_denominator; }
|
||||||
|
|
||||||
bool Fraction::operator==(const int n) const {
|
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 {
|
bool Fraction::operator==(const float n) const {
|
||||||
return (float(m_numerator) / float(m_denominator)) == n;
|
return (float(m_numerator) / float(m_denominator)) == n;
|
||||||
|
|
Reference in a new issue