mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Fixed 0^y for y > 0
While 0^0 == 1, now for y > 0, 0^y == 0. Adjusted cal/test8900.cal to reflect the this bug fix. Added tests to cal/regress.cal to help verify bug fix is fixed.
This commit is contained in:
9
value.c
9
value.c
@@ -1884,9 +1884,14 @@ powvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
*vres = error_value(E_1OVER0);
|
||||
break;
|
||||
}
|
||||
/* 0 ^ non-neg is 1, including 0^0 */
|
||||
vres->v_type = V_NUM;
|
||||
vres->v_num = qlink(&_qone_);
|
||||
if (qiszero(v2->v_num)) {
|
||||
/* 0 ^ 0 is 1 */
|
||||
vres->v_num = qlink(&_qone_);
|
||||
} else {
|
||||
/* 0 ^ (exp>0) is 0 */
|
||||
vres->v_num = qlink(&_qzero_);
|
||||
}
|
||||
} else if (qisint(real_v2)) {
|
||||
vres->v_num = qpowi(v1->v_num, real_v2);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user