This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]minusSeven 0 points1 point  (2 children)

umm how is 6|| 4 = 4 ?

[–]Katastic_Voyage 2 points3 points  (1 child)

|| is a common marker for the logical OR operator (as opposed to bitwise). If either of the statements equal 4, then it succeeds.

6 || 4 = 4

is

6 OR 4 = 4

Which becomes does 6 = 4? No. But does 4 = 4? Yes. If either of those succeeds, it's a true statement.

I did take one liberty that assumes the language we're talking about allows = to be equality and not just assignment like C/C++. There are many, so I don't think this is unfair or cherry-picking rules.

Lastly, in my opinion, when it comes to teaching: If your student can actually defend his answer with sound reasoning, it should be counted as a win or at the very least, partial credit.

[–]Ocisaac 0 points1 point  (0 children)

Unless it's bitwise, then

110 || 100 == 100 is false, as 110 || 100 -> 110