STEM4U: Improved Rational

git-svn-id: svn://ultimatepp.org/upp/trunk@14136 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2020-03-06 21:40:38 +00:00
parent 6b7a56b0a9
commit 3fdb823e19

View file

@ -118,19 +118,22 @@ public:
}
}
}
bool operator==(Rational& right) const {
bool operator==(Rational& right) {
Simplify();
right.Simplify();
return num == right.num && den == right.den;
}
template <typename T>
bool operator==(T right) const {
bool operator==(T right) {
Simplify();
if (den == 1)
return num == intInf(right);
else
return T(num/den) == right;
}
bool operator!=(Rational& right) const {return !operator==(right);}
bool operator!=(Rational& right) {return !operator==(right);}
template <typename T>
bool operator!=(T right) const {return !operator==(right);}
bool operator!=(T right) {return !operator==(right);}
template <typename T>
operator T() {