mirror of
https://github.com/c3d/DB48X-on-DM42.git
synced 2024-09-28 03:20:53 +02:00
expressions: Avoid error testing for zero/one in power operator
The power operator was calling `is_zero` and `is_one` with type checking enabled. This would cause a failure for an expression such as `e^(i*pi)` where the terms are constants. Fixes: #1007 Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
parent
488e192f82
commit
189694f6e5
2 changed files with 8 additions and 2 deletions
|
@ -892,7 +892,7 @@ algebraic_p arithmetic::non_numeric<struct pow>(algebraic_r x, algebraic_r y)
|
|||
// Deal with X^N where N is a positive or negative integer
|
||||
id yt = y->type();
|
||||
bool negy = yt == ID_neg_integer;
|
||||
bool posy = yt == ID_integer || y->is_zero() || y->is_one();
|
||||
bool posy = yt == ID_integer || y->is_zero(false) || y->is_one(false);
|
||||
if (negy || posy)
|
||||
{
|
||||
// Defer computations for integer values to integer_ok
|
||||
|
|
|
@ -162,7 +162,7 @@ void tests::run(bool onlyCurrent)
|
|||
if (onlyCurrent)
|
||||
{
|
||||
here().begin("Current");
|
||||
conditionals();
|
||||
complex_arithmetic();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3886,6 +3886,12 @@ void tests::complex_arithmetic()
|
|||
step("Do not promote symbols to complex");
|
||||
test(CLEAR, "2+3ⅈ 'A' +", ENTER)
|
||||
.expect("'(2+3ⅈ)+A'");
|
||||
|
||||
step("Complex expression involving constants")
|
||||
.test(CLEAR, LSHIFT, I, F1, F2, F3, F1, MUL, LSHIFT, B)
|
||||
.expect("'e↑(ⅈ·π)'")
|
||||
.test(LSHIFT, KEY1)
|
||||
.expect("1.∡180.°");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue