NOT

BASin

NOT

Logical Operator

NOT is used to reverse the truth of a condition so that a false condition becomes true and vice-versa.

How to use NOT

NOT is followed by a condition or by a numeric value, for example
90 IF NOT x=y+z THEN PRINT "Wrong"

or

90 LET correct=x=y+z: IF NOT correct THEN PRINT "Wrong"

When NOT is followed by a condition (x=y+z above), the BASIC first assigns a value of 1 to the condition if it is true and 0 if it is false. NOT then acts as a function, reversing the value produced, so that the reverse of the condition can be tested. Note that a condition should be enclosed in brackets if it contains AND or OR.

If NOT is followed by a numeric value, it returns 0 if the if the value following is non-zero and 1 if the value following is 0. Thus in the above examples, the BASIC prints "Wrong" if x<>y+z or if correct has a value of 0.

Format

  • NOT cond
  • NOT num-expr

See also

Chapter 13.