Boolean operator precedence

Edit on Github instead

Boolean operators, like mathematical ones, have an order of operations. When you're solving a boolean expression, follow this ordering:

  1. !
  2. ( and )
  3. == and !=
  4. &&
  5. ||
  6. The relational operators and arithmetic operators.

Let's test that with a few more boolean expressions:

Original Simplified Answer
!true || false false || false false
true || false && true true || false true
true == false && false true == false false
true != false || true true != true false

Suggest changes

Related links

URL Topic Source