mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
STEM4U: Improved Rational
git-svn-id: svn://ultimatepp.org/upp/trunk@14136 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
6b7a56b0a9
commit
3fdb823e19
1 changed files with 7 additions and 4 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue