Skip to content

Commit 9ae0175

Browse files
committed
Update cmpx.py
__itruediv__ & __ifloordiv__ got updated by changing the previous code when multiplying by the congugated denominator
1 parent 6199289 commit 9ae0175

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

cmpx.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def __idiv__(self, other):
101101
try:
102102
if not isinstance(other, Complex):
103103
other = Complex(other)
104-
den = other * Complex(other.re, - other.im)
105-
num = self * Complex(other.re, - other.im)
104+
den = other * other.con()
105+
num = self * other.con()
106106
self.re = num.re / den.re
107107
self.im = num.im / den.re
108108
return Complex(self.re, self.im)
@@ -113,8 +113,8 @@ def __ifloordiv__(self, other):
113113
try:
114114
if not isinstance(other, Complex):
115115
other = Complex(other)
116-
den = other * Complex(other.re, - other.im)
117-
num = self * Complex(other.re, - other.im)
116+
den = other * other.con()
117+
num = self * other.con()
118118
self.re = num.re // den.re
119119
self.im = num.im // den.re
120120
return Complex(self.re, self.im)

0 commit comments

Comments
 (0)