• cengland0 (10/14/2009)


    I would agree except the question did not say, Why doesn't this produce the expected result of 56? It was not a troubleshooting question but a question about the operators AND and OR.

    I don't think the question said anything other than "What is the output of the above"?

    I agree that the title could have been changed so that it wasn't misleading but still didn't give the game away. "Bitwise" may have been more appropriate?

    All I'm saying is I can see where the question poser is coming from and I quite liked it as it translates well to real world situations, and it's a lesson that is normally learned the hard way. Put it this way, if a dev came to you and asked what was going on, and the variable declarations were nowhere near the code in question, and they'd been mulling this over for a while and specifically asked you to look at their AND/OR operator logic as they were so far up the wrong tree they couldn't see the way back down, how many people would first say, "right, what are the datatypes you're using here?"

    - I'm pretty sure I would get suckered into the same staring, head scratching routine and it could take quite a while to get to the bottom of it...

    --------
    [font="Tahoma"]I love deadlines. I like the whooshing sound they make as they fly by. -Douglas Adams[/font]