View Single Post
Old 08-28-2009, 09:35 AM   #20
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

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 View Post
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)

Last edited by Jeffos; 08-28-2009 at 12:17 PM.
Jeffos is offline   Reply With Quote