summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
54e7ce4)
Pointed out by: Steven A. Reisman
int op = *s++;
int y = eval_op_unary(&s, decimal, error);
if (*error != NULL) break;
int op = *s++;
int y = eval_op_unary(&s, decimal, error);
if (*error != NULL) break;
- if (op == '*') x *= y;
- else if (op == '/')
+ if (op == '*')
+ x *= y;
+ else
+ {
+ if (y == 0)
- if (y == 0)
- {
- *error = US"divide by zero";
- x = 0;
- break;
- }
- x /= y;
+ *error = (op == '/') ? US"divide by zero" : US"modulo by zero";
+ x = 0;
+ break;
+ if (op == '/')
+ x /= y;
+ else
+ x %= y;
+ }