← All exercises

Word Invert

easy

Outputs the bitwise complement of an integer input — every bit flipped.

What it teaches

Bitwise NOT flips all 32 bits of a DINT at once. Unlike Lamp Inverted, the input is a packed word rather than one BOOL. The everyday uses: flip a mask so AND clears bits instead of keeping them, and turn an active-low status word — where 0 means fault — back into readable logic.

Inputs and outputs

TagTypeDefaultDescription
In_WordDINT5Word to complement
Out_WordDINTBitwise complement of the input

Required behavior

  • Every bit of Out_Word is the opposite of the same bit in In_Word, all 32 at once.
  • Because DINT is signed, flipping every bit of 5 produces -6.
  • The complement of 0 is -1 (all 32 bits set), and the complement of -1 is 0.