mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Fixed 0^(0) and 0^(6-6) to return 1
Calc as defined 0^0 as 1. However in the past, 0 raised to an expression that evaluted to zero returned 1. The result was that 0^0 was different than 0^(6-6) or even 0^(0). Now, calc will return 1 for 0^(0) and 0^zero when zero == 0.
This commit is contained in:
4
value.c
4
value.c
@@ -1879,9 +1879,9 @@ powvalue(VALUE *v1, VALUE *v2, VALUE *vres)
|
||||
*vres = error_value(E_1OVER0);
|
||||
break;
|
||||
}
|
||||
/* 0 ^ non-neg is zero, including 0^0 */
|
||||
/* 0 ^ non-neg is 1, including 0^0 */
|
||||
vres->v_type = V_NUM;
|
||||
vres->v_num = qlink(&_qzero_);
|
||||
vres->v_num = qlink(&_qone_);
|
||||
} else if (qisint(real_v2)) {
|
||||
vres->v_num = qpowi(v1->v_num, real_v2);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user