Bug in division eval

This commit is contained in:
2021-01-23 21:44:44 +01:00
parent e1c734cb63
commit 684c33f156

7
eval.c
View File

@@ -63,15 +63,20 @@ int eval_node(node, depth, pvals, pops, ncalcs)
res=val1+val2;
break;
case Mul:
if (val1 > 1 && val2 > 1) /* we avoid "x*1" */
res=val1*val2;
break;
case Sub:
if (val1 > val2)
res=val1-val2;
if (res == val2) /* we already got this value in tree */
res=-1;
break;
case Div:
if (val1 > val2 && (val1 % val2 == 0))
if (val1 >= val2 && val2 != 1 && (val1 % val2 == 0))
res=val1/val2;
if (res == val2) /* we already got this value in tree */
res=-1;
break;
case Nop:
case End: