Skip to content

Commit

Permalink
Merge pull request #149 from Vardan2009/master
Browse files Browse the repository at this point in the history
fix: Integer division issue
  • Loading branch information
Almas-Ali authored May 29, 2024
2 parents 8503174 + b026b79 commit dd36da0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions core/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def idived_by(self, other: Value) -> ResultTuple:
if isinstance(other, Number):
if other.value == 0:
return None, RTError(other.pos_start, other.pos_end, "Division by zero", self.context)

return Number(self.value // other.value).set_context(self.context), None
return Number(int(self.value // other.value)).set_context(self.context), None
else:
return None, Value.illegal_operation(self, other)

Expand Down
2 changes: 1 addition & 1 deletion core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def arith_expr(self) -> ParseResult[Node]:
return self.bin_op(self.term, (TT_PLUS, TT_MINUS))

def term(self) -> ParseResult[Node]:
return self.bin_op(self.factor, (TT_MUL, TT_DIV, TT_MOD))
return self.bin_op(self.factor, (TT_MUL, TT_DIV, TT_MOD, TT_IDIV))

def factor(self) -> ParseResult[Node]:
res = ParseResult[Node]()
Expand Down
2 changes: 1 addition & 1 deletion tests/incdec.rn.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"code": 0, "stdout": "69\n70\n69\n69\n70\n71\n72\n71\n70\n----------------\n69 69\n69 70\n----------------\n69\n74\n69\n345\n69.0\n1564031349.0\n312806269.0\n4.0\n", "stderr": ""}
{"code": 0, "stdout": "69\n70\n69\n69\n70\n71\n72\n71\n70\n----------------\n69 69\n69 70\n----------------\n69\n74\n69\n345\n69.0\n1564031349.0\n312806269\n4\n", "stderr": ""}

0 comments on commit dd36da0

Please sign in to comment.