Bring behaviour inline with joytest.

Pop has it's own error message.

Div should be "floor" division

> fdiv rounds q down towards -infinity, and r will have the same sign as
> d. The f stands for “floor”.

https://gmplib.org/manual/Integer-Division
This commit is contained in:
Simon Forman 2023-02-12 16:01:19 -08:00
parent 4330c26cef
commit b6d4175a78
1 changed files with 6 additions and 2 deletions

View File

@ -558,8 +558,8 @@ name(JoyListPtr stack, __attribute__((unused)) JoyListPtr expression) \
BINARY_MATH_OP(add)
BINARY_MATH_OP(sub)
BINARY_MATH_OP(mul)
BINARY_MATH_OP(tdiv_q)
BINARY_MATH_OP(tdiv_r)
BINARY_MATH_OP(fdiv_q)
BINARY_MATH_OP(fdiv_r)
/*
@ -639,6 +639,10 @@ cons(JoyListPtr stack, __attribute__((unused)) JoyListPtr expression)
void
pop(JoyListPtr stack, __attribute__((unused)) JoyListPtr expression)
{
if (!(*stack)) {
printf("Cannot pop empty stack.\n");
longjmp(jbuf, 1);
}
pop_any(stack);
}