From 3fdb823e199604f2dca2b9237a0b189e455f6986 Mon Sep 17 00:00:00 2001 From: koldo Date: Fri, 6 Mar 2020 21:40:38 +0000 Subject: [PATCH] STEM4U: Improved Rational git-svn-id: svn://ultimatepp.org/upp/trunk@14136 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/STEM4U/Rational.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bazaar/STEM4U/Rational.h b/bazaar/STEM4U/Rational.h index b428e3444..48963dbfd 100644 --- a/bazaar/STEM4U/Rational.h +++ b/bazaar/STEM4U/Rational.h @@ -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 - 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 - bool operator!=(T right) const {return !operator==(right);} + bool operator!=(T right) {return !operator==(right);} template operator T() {