Solve bug with simplification of fractions

This commit is contained in:
Lafrite 2014-09-02 11:44:04 +02:00
parent 412149f22d
commit eb1088d31f
2 changed files with 3 additions and 2 deletions

View File

@ -331,6 +331,7 @@ def test(exp):
print("\n") print("\n")
if __name__ == '__main__': if __name__ == '__main__':
Expression.STR_RENDER = txt
#exp = "2 ^ 3 * 5" #exp = "2 ^ 3 * 5"
#test(exp) #test(exp)

View File

@ -37,8 +37,8 @@ class Fraction(object):
n_frac = self n_frac = self
gcd_ = gcd(abs(n_frac._num), abs(n_frac._denom)) gcd_ = gcd(abs(n_frac._num), abs(n_frac._denom))
if n_frac._num == n_frac._denom: if gcd_ == n_frac._denom:
n_frac = Fraction(1,1) n_frac = n_frac._num // gcd_
steps.append(n_frac) steps.append(n_frac)
elif gcd_ != 1: elif gcd_ != 1: