/mod must be unsigned

This commit is contained in:
Koichi Nakamura 2021-01-11 12:56:12 +09:00
parent 04aa3351ba
commit bafbf5959a
2 changed files with 4 additions and 4 deletions

View file

@ -148,8 +148,8 @@ defcode("f", find_) { push((cell) find(pop())); next(); }
defcode("v", argv_) { push((cell) saved_argv); push(saved_argc); next(); }
defcode("V", impl) { push((cell) VERSION); next(); }
defcode("/", divmod) {
intptr_t b = pop();
intptr_t a = pop();
uintptr_t b = pop();
uintptr_t a = pop();
push(a%b);
push(a/b);
next();

View file

@ -226,8 +226,8 @@ def litstring(ip, np):
return next(np + CELL + read(np))
add_operator('S', litstring)
def divmod():
b = ctypes.c_int(pop()).value
a = ctypes.c_int(pop()).value
b = pop()
a = pop()
push(a%b)
push(a//b)
add_simple_operator('/', divmod)