Skip to content

Commit a6c65e8

Browse files
authored
Update Basic Calculator.py
1 parent 54061e4 commit a6c65e8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Basic Calculator.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ def update(self, stack, op, tmp):
3737
elif op == '*':
3838
stack[-1] *= tmp
3939
elif op == '/':
40-
stack[-1] //= tmp
40+
if stack[-1] >= 0:
41+
stack[-1] //= tmp
42+
else:
43+
stack[-1] = -(-stack[-1] // tmp)
4144

4245
def cal(self, s, idx):
4346
stack = []

0 commit comments

Comments
 (0)