Acolmiztli ·
When you write something like out = (x > xMustBeBiggerThan) & in; What are you basically saying in prose terms?
Is there any guide on the syntax and general usage of the code module yet?
From the original SynthMaker forum (2004–2014), with its members’ names and dates.
Acolmiztli ·
When you write something like out = (x > xMustBeBiggerThan) & in; What are you basically saying in prose terms?
Is there any guide on the syntax and general usage of the code module yet?
infuzion ·
Yes, but I don't quite get the code thing yet, esp compairisons.
rl ·
The '&' operator is a logical AND
The comparison operator creates a mask:
so x < y is either 0 or 11111111111111111111111111111111 (bit-wise)
0 & x gives always 0 11111111111111111111111111111111 & x gives always x
if x > xMustBeBiggerThan we have out = 111....111 & in, so out = in if x <= xMustBeBiggerThan we have out = 0 & in, so out = 0
so basically the statement means:
if (x > xMustBeBiggerThan) out = in else out =0;
Acolmiztli ·
right.. so if a condition within the parenthesis is true, it performs the AND... if its false, what does it do? Does it just stop there and not perform the AND, or is the AND performed always?
unkargherth ·
If the condition it's false , you could consider there's "hidden" &0.
a=(a<=0.5)&1; /* This reads
if (a>=0.5) then a=1; else a=0; */
Obviously &0 means set something to ZERO, if you want something diferent try like this
a=(n<=0.5)&(2*a)+(n>0.5)&(0.95*a); /* This reads
if (n>=0.5) then a=2*a; else a=0.95*a; */
Be carefult at this point. The two conditions are complementary and exclusive: if first is true, second is false and reverse
Rellik ·
Acolmiztli wrote: right.. so if a condition within the parenthesis is true, it performs the AND... if its false, what does it do? Does it just stop there and not perform the AND, or is the AND performed always?
Nope, it doesn't stop. The code just keeps going - it always performs the AND. But the AND will have a different result depending on the result of "x > xMustBeGreaterThan". That is why there are two results for "out" - "out" is equal to "in" when "x > xMustBeGreaterThan" is true (the big 11111111111111 thing means it's true), since true AND "in" is "in" - and if "x > xMustBeGreaterThan" is false (0), then "out" is equal to "in" AND false, which is 0.
Shifrin ·
Just for reference you can chain together these (<comparison>)&... expressions, i.e. :-
x = (x < 0.5)&(x > 0.0)&(0.123*x);
Would be :-
if(x < 0.5 && X > 0.0) { x = 0.123*x; } else { x = 0; }
Shif.
Acolmiztli ·
can anyone say HEADACHE!!!
hehe. Thanks guys.
Wrote something here? To have a post removed or your name hidden, write to [email protected].