To easily test if the value of a flag is FALSE, you can use the logical negation operator, !. In the expression
if ( ! isPrime )
the logical negation operator is used to test if the value of isPrime is FALSE (read this statement as “if not isPrime”). In general, an expression such as
! expression
negates the logical value of expression. So if expression is zero, the logical negation operator produces a 1. And if the result of the evaluation of expression is nonzero, the negation operator yields a 0.
The logical negation operator can be used to easily “flip” the value of a flag, such as in the expression
myMove = ! myMove;
As you might expect, this operator has the same precedence as the unary minus operator, which means that it has higher precedence than all binary arithmetic operators and all relational operators. So to test if the value of a variable x is not less than the value of a variable y, such as in
! ( x < y )
the parentheses are required to ensure proper evaluation of the expression. Of course, you could have equivalently expressed the previous expression as
x >= y