Abstract

The boolean operators.  AKA logical operators, are used to perform boolean Boolean OR, Boolean AND, and Boolean NOT operations.  Boolean values are typically used to control iterations or selections.  In C.  there is no Boolean type; int values are commonly used as Boolean, with 0 representing false, and any non-zero value representing true.

Form

boolean-operator
boolean-and-operator | boolean-or-operator | boolean-not-operator
boolean-and-operator
&&
boolean-or-operator
||
boolean-not-operator
!

Domain

boolean-and-operator
&&: int × int &rarr int
boolean-or-operator
||: int × int &rarr int
boolean-not-operator
!: int &rarr int

Semantics

boolean-or-operator
The Boolean OR operator has its usual mathematical meaning, but short circuit evaluation is used.
boolean-and-operator
The Boolean AND operator has its usual mathematical meaning, but short circuit evaluation is used.
boolean-not-operator
The Boolean NOT operator has its usual mathematical meaning.

Side Effects

boolean-operator
Boolean operators have no side effects.

Commutativity

boolean-or-operator
Tha Boolean || (OR) operator is not semantically commutative.
Tha Boolean OR operator is mathematically commutative.
boolean-and-operator
Tha Boolean && (AND) operator is not semantically commutative.
Tha Boolean AND operator is mathematically commutative.

Associativity

boolean-operator
The boolean operators associate left to right syntactically.
boolean-or-operator
The Boolean OR operator is mathematically associative.
boolean-and-operator
The Boolean AND operator is mathematically associative.

Precedence


Higher
Subscript [ ]
UnaryPostfix ++ --
Prefix ++ -- + - ! ~ ()
Arithmetic Multiplicative * / %
Additive + -
Shift >> <<
ComparisonRelational < <= > >=
Equality == !=
Bitwise Bitwise AND &
Bitwise XOR ^
Bitwise OR |
Boolean Boolean AND &&
Boolean OR ||
Conditional ? :
Assignment = += -= *= /= %= &= |= ^= <<= >>=
Sequence ,

Remarks

Reference Links

Boolean Operators
boolean-operator
Boolean AND Operator boolean-and-operator
Boolean OR Operator boolean-or-operator
Boolean NOT Operator boolean-not-operator

Other Languages

C Now
C Boolean Operators
C++ Now C++ Boolean Operators
C# Now C# Boolean Operators
Java Now Java Boolean Operators