Quote:
Originally Posted by Alan Anderson
It makes sense if you're averse to using procedural programming and prefer functional programming. The logic behind your code gives the same result as the one using if statements, but the reason for doing it that way is obscure to anyone encountering it cold.
And it takes a lot more time to do it your way. A few comparisons and branches are faster than many multiplications and additions. Note that the original code never does more than three comparisons and one assignment. Yours always does six multiplications, thirteen additions, and one comparison. It would be instructive to compile both alternatives and compare the generated assembly language code in the listing file.
As an aside, wouldn't it work just as well to simplify the condition to this?
Code:
if ( ( Button1 + Button2 + Button3 ) == 1 )
|
hahaha
wow. this is what no sleep does to you.
thanks for that.
maybe I just think weird or something