summaryrefslogtreecommitdiffstats
path: root/general/Frac.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'general/Frac.cpp')
-rw-r--r--general/Frac.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/general/Frac.cpp b/general/Frac.cpp
index 9cf47aca..317fdc53 100644
--- a/general/Frac.cpp
+++ b/general/Frac.cpp
@@ -24,7 +24,7 @@
void Frac::set(const int n, const int d) throw(Exception)
{
- if (((type == Improper) || ((n <= d) && (type == Proper)) || ((d < n) && (type == Over1))) && (0 < d))
+ if (((type == Improper) || ((n <= d) && (type == Proper)) || ((d <= n) && (type == Over1))) && (0 < d))
{
num = n;
denom = d;
@@ -64,13 +64,8 @@ void Frac::reduce()
{
int i = num;
int j = denom;
- int k;
- while (j)
- {
- k = j;
- j = i % j;
- i = k;
- }
+ while (i - j)
+ (i > j) ? (i -= j) : (j -= i);
num /= i;
denom /= i;
}