complement

operator

Return type: Integer
Returns:       A bit sequence.

Syntax
complement numeric-expression


Purpose

The complement of two bit sequences is a new sequence where each bit is "flipped". In other words, each bit is:

  • 1 if the corresponding operand is 0
  • 0 if the corresponding operand is 1

For example, the complement of 0 is "111111111111111111111111111111111111" base 2. (This actually results in a negative number on most systems because the topmost bit is a sign bit. A "1" in this position usually indicates a negative number. This is one reason to avoid dealing with numeric expressions as both bit sequences and numbers at the same time.)

Other languages sometimes refer to this operator as a "bit-wise not" because the operation is analogous to the logical "not" operation. To avoid confusion, OmniMark reserves the operator "!" (not) for the logical "not" operation.

Usage example:

  set c to complement 1
  
  set c to c mask complement 1

Related Concepts