mirror of
https://github.com/pocketpy/pocketpy
synced 2025-11-09 13:10:17 +00:00
Some changes
This commit is contained in:
parent
6b80256929
commit
e237a7dfa2
@ -68,6 +68,8 @@ class complex:
|
||||
def __truediv__(self, other):
|
||||
if type(other) is complex:
|
||||
denominator = other.real ** 2 + other.imag ** 2
|
||||
if denominator == 0:
|
||||
raise ZeroDivisionError("Division by zero in complex number division")
|
||||
real_part = (self.real * other.real + self.imag * other.imag) / denominator
|
||||
imag_part = (self.imag * other.real - self.real * other.imag) / denominator
|
||||
return complex(real_part, imag_part)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user