Skip to content

Commit

Permalink
Make # for radicals more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
kg583 committed Nov 16, 2024
1 parent d75c01c commit e14a6d6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tivars/types/real.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,11 @@ def reduce(part):
case _:
return part

left = reduce(f"{self.left_scalar * (-1 if self.sign_type % 2 else 1)}{self.left_radicand}")
right = reduce(f"{self.right_scalar * (-1 if self.sign_type > 1 else 1)}{self.right_radicand}")

match format_spec:
case "":
left = reduce(f"{self.left_scalar * (-1 if self.sign_type % 2 else 1)}{self.left_radicand}")
right = reduce(f"{self.right_scalar * (-1 if self.sign_type > 1 else 1)}{self.right_radicand}")

match left, right, self.denominator:
case "", "", _:
string = "0"
Expand All @@ -440,6 +440,9 @@ def reduce(part):
return string.replace("+-", "-")

case "#":
left = f"{self.left_scalar * (-1 if self.sign_type % 2 else 1)}{self.left_radicand}"
right = f"{self.right_scalar * (-1 if self.sign_type > 1 else 1)}{self.right_radicand}"

return f"({left}+{right})/{self.denominator}".replace("+-", "-")

case _:
Expand Down

0 comments on commit e14a6d6

Please sign in to comment.