Dec 27, 2010 at 10:41am Dec 27, 2010 at 10:41am UTC
Greetings All
I'm battling to understand the following code segment:
float m,n,gamma;
...
...
float y1 = (n - m & 1 ? -gamma : gamma);
m, n and gamma are assigned values elsewhere in the code. What I can't figure out are the meanings of "?" and ":" in this context. Would anyone be able to explain this to me?
Cheers
Rich
Last edited on Dec 27, 2010 at 10:42am Dec 27, 2010 at 10:42am UTC
Dec 27, 2010 at 11:13am Dec 27, 2010 at 11:13am UTC
Cool Bazzy, thanks for the light speed reply and the link.
So to my understanding, this means
1 2 3 4 5 6 7 8
//if (n - m != 0), y1 = gamma
//but if n - m = 0, y1 = -gamma
//i.e.
if (n - m & 1)
y1 = gamma;
else
y1 = -gamma;
assuming that True = 1 and False = NOT 1 in this case... would that be correct?
Last edited on Dec 27, 2010 at 11:44am Dec 27, 2010 at 11:44am UTC
Dec 27, 2010 at 12:07pm Dec 27, 2010 at 12:07pm UTC
Brilliant. That makes sense. Cheers!