### Boolean Expressions

Boolean expressions are used to manipulate logical values (In the form of true/false, on/off, 0/1 etc.)

MP provides standard Boolean operators as well as useful functions to do Boolean Algebra.

Following are MP's Boolean operators:

OperationOperatorComment
NOT ~ or ! Logical Negation
OR + Logical OR
AND * Logical AND
XOR ^ Exclusive OR
Conditional ? Logical condition as in: if p then q
Bi-Conditional ?? As in: p if and only if q

Note: NOT has the highest priority. Next comes XOR followed by AND. The operators OR, Conditional and Bi-Conditional have equal (and the lowest) priority. Use parentheses to avoid any confusion with the priority of operators.

Details of these operations are given below.

### NOT (~ or !)

MP uses the operator '~' (prime) or '!' as Boolean (logical) NOT. The truth table for NOT is:

p~p
1 0
0 1

### OR (+)

MP uses the operator '+' as Boolean (logical) OR. The Boolean '+' operator should not be confused with arithmetic operator '+'. Math Processor knows which of these to apply based on the type of the operands. If the type of operands is numeric, + will be used as the arithmetic operator. If the type of operands is Boolean, OR operation will be performed. If the types are different, MP will complain. The truth table for OR is:

pqp + q
1 1 1
1 0 1
0 1 1
0 0 0

### AND (*)

MP uses the operator '*' as Boolean (logical) AND. The Boolean '*' operator should not be confused with the multiplication operator '*'. Math Processor knows which of these to apply based on the type of the operands. If the type of operands is numeric, * will be used as the multiplication operator. If the type of operands is Boolean, AND operation will be performed. If the types are different, MP will complain. The truth table for AND is:

pqp * q
1 1 1
1 0 0
0 1 0
0 0 0

### XOR (^)

MP uses the operator '^' as Boolean (logical) XOR (Exclusive OR). The Boolean '^' operator should not be confused with the power operator '^'. Math Processor knows which of these to apply based on the type of the operands. If the type of operands is numeric, ^ will be used as the power operator. If the type of operands is Boolean, XOR operation will be performed. If the types are different, MP will complain. The truth table for XOR is:

pqp ^ q
1 1 0
1 0 1
0 1 1
0 0 0

### Conditional (?)

MP uses the operator '?' as Boolean (logical) condition i.e. for expressions of the form: if p then q. The truth table for conditional operator is:

pqp ? q
1 1 1
1 0 0
0 1 1
0 0 1

### Bi-Conditional (??)

MP uses the operator '??' as Boolean (logical) Bi-Conditional i.e. expressions of the form: p if and only if q. The truth table for Bi-conditional operator is:

pqp ?? q
1 1 1
1 0 0
0 1 0
0 0 1