seveianrex
10-23-2008, 06:45 PM
Okay, admittedly I'm a self taught programmer and I never quite understood binary operators.
In working with the "CLASSES" column for AA's I was able to get a grasp on the binary 'AND' (&) operator, and I understand how bitshifting (1 << value) works.
I was curious though... I've seen some very elegant looking code before in terms of something like the following:
switch (GetAA(aaNumberOne) | GetAA(aaNumberTwo))
{
//blah
}
which would utilize the non-zero value.
would the above code work? if aaNum1 returned 0 and aaNum2 returned 3, for example, would it switch (3) ?
just seems a lot more elegant than doing two switches that do the same thing. i realize i could use an integer variable too, but that gets clunky lookin'.
In working with the "CLASSES" column for AA's I was able to get a grasp on the binary 'AND' (&) operator, and I understand how bitshifting (1 << value) works.
I was curious though... I've seen some very elegant looking code before in terms of something like the following:
switch (GetAA(aaNumberOne) | GetAA(aaNumberTwo))
{
//blah
}
which would utilize the non-zero value.
would the above code work? if aaNum1 returned 0 and aaNum2 returned 3, for example, would it switch (3) ?
just seems a lot more elegant than doing two switches that do the same thing. i realize i could use an integer variable too, but that gets clunky lookin'.