Commit a9d59f15 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

sync [pow] inf/nan handling with [pow~]

parent 0e27f1d4
......@@ -143,32 +143,16 @@ static void *binop1_pow_new(t_floatarg f)
static void binop1_pow_bang(t_binop *x)
{
if (x->x_f1 >= 0)
outlet_float(x->x_obj.ob_outlet,
POW(x->x_f1, x->x_f2));
else if (x->x_f2 <= -1 || x->x_f2 >= 1 || x->x_f2 == 0)
outlet_float(x->x_obj.ob_outlet,
POW(x->x_f1, x->x_f2));
else
{
pd_error(x, "pow: calculation resulted in a NaN");
outlet_float(x->x_obj.ob_outlet, 0);
}
t_float r = (x->x_f1 == 0 && x->x_f2 < 0) ||
(x->x_f1 < 0 && (x->x_f2 - (int)x->x_f2) != 0) ?
0 : POW(x->x_f1, x->x_f2);
outlet_float(x->x_obj.ob_outlet, r);
}
static void binop1_pow_float(t_binop *x, t_float f)
{
x->x_f1 = f;
if (x->x_f1 >= 0)
outlet_float(x->x_obj.ob_outlet,
POW(x->x_f1, x->x_f2));
else if (x->x_f2 <= -1 || x->x_f2 >= 1 || x->x_f2 == 0)
outlet_float(x->x_obj.ob_outlet,
POW(x->x_f1, x->x_f2));
else {
pd_error(x, "pow: calculation resulted in a NaN");
outlet_float(x->x_obj.ob_outlet, 0);
}
binop1_pow_bang(x);
}
/* ------------------------ max -------------------------------- */
......
#N canvas 591 76 749 617 12;
#N canvas 372 60 749 617 12;
#X obj 345 301 r \$0-result;
#X obj 345 326 route 0;
#X obj 453 470 print failure;
#X obj 430 336 tgl 28 0 empty empty Print_All_Results 31 11 0 12 -262144
-1 -1 0 1;
-1 -1 1 1;
#X obj 159 149 bng 31 250 50 0 empty empty Run_all 39 13 0 12 -262144
-1 -1;
#X obj 56 25 r init;
......@@ -37,6 +37,7 @@ is handy for some binbuf tests.;
#X obj 391 374 spigot;
#X obj 407 440 route 1;
#X obj 407 495 print success;
#X obj 145 353 rtest pow_0.49_compatibility;
#X connect 0 0 1 0;
#X connect 1 0 7 0;
#X connect 1 1 29 0;
......@@ -56,6 +57,7 @@ is handy for some binbuf tests.;
#X connect 15 0 13 0;
#X connect 16 0 17 0;
#X connect 17 0 18 0;
#X connect 18 0 32 0;
#X connect 20 0 21 0;
#X connect 21 0 22 0;
#X connect 22 0 14 0;
......
#N canvas 615 60 534 596 12;
#X obj 46 21 inlet;
#X obj 46 383 r \$0-test;
#X obj 46 410 list split 3;
#X obj 46 435 unpack 0 0 0;
#X obj 46 498 ==;
#X obj 46 527 list append;
#X obj 46 552 outlet;
#X obj 46 46 t b b;
#X obj 78 152 send pd;
#X obj 46 467 pow;
#X msg 46 180 \; \$0-test 2 2 4 standard positive base and positive
exponent \; \$0-test 0 2 0 bash to zero with zero base and positive
exponent \; \$0-test 0 -2 0 bash to zero with zero base and negative
exponent \; \$0-test 2 -2 0.25 standard positive base and negative
exponent \; \$0-test -2 -2 0.25 standard negative base and negative
exponent \; \$0-test -2 2 4 standard with negative base and positive
exponent;
#X msg 78 127 compatibility 0.49;
#X text 99 21 Code coverage test for compatibility with the 0.49 Vanilla
pow behavior. We use the "compatibility" message to set compatibility
to 0.49. Our testing framework makes sure to set compatibility back
to the recent version. We might want to generalize this test for more
tilde unit tests later...;
#X connect 0 0 7 0;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 2 1 5 1;
#X connect 3 0 9 0;
#X connect 3 1 9 1;
#X connect 3 2 4 1;
#X connect 4 0 5 0;
#X connect 5 0 6 0;
#X connect 7 0 10 0;
#X connect 7 1 11 0;
#X connect 9 0 4 0;
#X connect 11 0 8 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment