Hey! IXix! I use it, I forget to thank you for that in the other thread! Very handy especially in comparison with how I was debugging arrays before
Quote:
Originally Posted by Justin
I think it depends on what condi1 refers to.. If it's mostly 0, then 2) should be faster. Other cases, the difference becomes less I'd think.
|
Thanks for the feedback, Mr Frankel! The "boolean" "cond" meant a variable that's either 0 or 1 and nothing else. So, in both cases, I was hoping some stuff not to be evaluated in "cond * something_else" as the result is either 0 or something_else.
Here's the not-good-for-speakers code I used to test that (where "cond" is often updated as you can see):
Code:
desc:Jeff test 27
slider1:0<0,1,1{1,2}>Mode
@init
cond=0;
@sample
cond = !cond;
!slider1 ?
// 1)
(spl0 = cond * floor(rand(spl0) * $pi * 100);)
// 2)
: (cond ? spl0 = floor(rand(spl0) * $pi * 100) : spl0 = 0;);
As logical operations use operator precedence, I also tried "spl0 = cond && (floor(rand(spl0) * $pi * 100))" that is to say "&&" instead of "*" but it's ko: logical operations clamp results to 0 or 1 (edit: and that's fine)