mirror of
https://github.com/Sosokker/Calculator-for-Matrix-and-Algebra.git
synced 2025-12-18 20:54:05 +01:00
Fix bug in to_str()
This commit is contained in:
parent
d2189d9f0e
commit
1e1aa128a4
@ -134,7 +134,7 @@ class Polynomial:
|
|||||||
# return "+".join(result)
|
# return "+".join(result)
|
||||||
# else:
|
# else:
|
||||||
# return "0"
|
# return "0"
|
||||||
|
last_count = len(str(self.coeff[-1]))
|
||||||
result = []
|
result = []
|
||||||
i = len(self.coeff) - 1
|
i = len(self.coeff) - 1
|
||||||
while i >= 0:
|
while i >= 0:
|
||||||
@ -168,8 +168,13 @@ class Polynomial:
|
|||||||
if result[0] == "+" or result[0] == "-":
|
if result[0] == "+" or result[0] == "-":
|
||||||
del result[0]
|
del result[0]
|
||||||
result = "".join(result)
|
result = "".join(result)
|
||||||
|
|
||||||
return result
|
if self.coeff[-1] > 0:
|
||||||
|
return result[last_count:]
|
||||||
|
elif self.coeff[-1] < 0:
|
||||||
|
return result[last_count-1:]
|
||||||
|
else:
|
||||||
|
return result
|
||||||
|
|
||||||
def solve(self) -> dict:
|
def solve(self) -> dict:
|
||||||
degree = len(self.coeff) - 1
|
degree = len(self.coeff) - 1
|
||||||
@ -266,7 +271,7 @@ class Polynomial:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.string_form
|
return self.to_str()
|
||||||
|
|
||||||
|
|
||||||
# p1 = Polynomial("x^2+2x+1", fracmode=True)
|
# p1 = Polynomial("x^2+2x+1", fracmode=True)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user