NOT

Top  Previous  Next

The logical operator NOT operates on expressions with the BOOL, SINT, INT, and DINT data types. When operating on data types other than BOOL, the operation is bitwise (which is to say that all "1" bits will be set to "0" and vice versa). When operating on BOOL, it has the following truth table:

 

 

  Input      Output

-----------------------

     0              1      

     1              0      

-----------------------

 

It can also be used in #IFDEF conditional compilation directive.

 

Example:

INCLUDE rtcu.inc
 
VAR
  a : BOOL;
  i : INT;
  j : INT;
END_VAR;
 
PROGRAM test;
 
BEGIN
  ...
  i:=16#00FF;
  j:=NOT i;
  // Now j is 16#FF00
  ...
  IF NOT a THEN
    // This will be executed if a are FALSE
     ...
  END_IF;
  ...
END;
 
END_PROGRAM;