Feat: no more round in quadratic roots

This commit is contained in:
Bertrand Benjamin 2019-07-17 09:55:32 +02:00
parent e52fec4057
commit 02214b0f82
1 changed files with 6 additions and 4 deletions

View File

@ -288,13 +288,15 @@ class Quadratic(Polynomial):
return [round(eval(f"-{self.b}/(2*{self.a})"), 2)]
else:
from math import sqrt
roots = [
round(eval(f"(-{self.b}-sqrt({self.delta}))/(2*{self.a})"), 2),
round(eval(f"(-{self.b}+sqrt({self.delta}))/(2*{self.a})"), 2),
str(eval(f"(-{self.b}-sqrt({self.delta}))/(2*{self.a})")),
str(eval(f"(-{self.b}+sqrt({self.delta}))/(2*{self.a})")),
]
roots.sort()
return roots
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4: