Skip to content

Commit

Permalink
Fix some conversion errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Middledot committed Jun 30, 2022
1 parent f4765ed commit 5683892
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions math_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ def resolve_expr(expr: str, **keys: Dict[str, str]) -> NumberType:
return resolve_from_listable(listable)

def to_num_type(string: str) -> NumberType:
if "." in string and ".0" not in string:
if string.endswith(".0"):
string = string.split(".", 1)[0]
if "." in string:
try:
res = float(string)
except ValueError:
Expand All @@ -171,7 +173,7 @@ def resolve_from_listable(listable) -> NumberType:
smallest = min(shortest_res.keys())
the_op = shortest_res[smallest]

num1, num2 = to_num_type(listable[smallest-1]), to_num_type(listable[smallest+1])
num1, num2 = to_num_type(str(listable[smallest-1])), to_num_type(str(listable[smallest+1]))

result = to_num_type(str(_resolve_simple_eq(the_op, num1, num2)))

Expand Down

0 comments on commit 5683892

Please sign in to comment.