1
$\begingroup$

Hello I need help with xy xor z, do I do the logic AND first or the XOR, no parenthesis. Thank You

$\endgroup$
  • 2
    $\begingroup$ That would depend on how one chooses the precedence between those two connectives -- this is a convention, not a scientific fact. However, I'd guess it's AND first, since I always found that precedence to be used in my experience. $\endgroup$ – chi May 7 '17 at 17:08
  • $\begingroup$ Usually AND has priority over OR and XOR like multiplications have priority over additions : AND is a 1 bit binary multiplication, XOR is a 1 bit binary addition. $\endgroup$ – TEMLIB May 7 '17 at 19:40
1
$\begingroup$

Usually, an operator that's written implicitly by just putting the operands next to each other (e.g., "$xy$" for $x\land y$ in logic or $x\times y$ in arithmetic) has precedence over binary operators that are written out explicitly (e.g., $\lor$ or $\oplus$ in logic, or $+$ in arithmetic). Indeed, any author who uses a different convention to that needs a good stern talking to. But note that it is only a convention.

So the expression in the question means $(xy)\oplus z$, unless the person who wrote it hates us. This view is reinforced by the fact that logical and is multiplication modulo 2, and xor is addition modulo 2 and we'd expect multiplication to have precedence over addition.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.