[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
xor                      Logical and Integer Operator XOR (Exclusive OR)

 <bool exp> xor <bool exp>  { does a logical xor; result is Boolean }
 <int exp>  xor <int exp>   { does a bitwise xor; result is Integer }    [TP]

    The operator XOR (exclusive OR) can be used for both boolean and
    integer expressions. For boolean expressions, it uses the left truth
    table below:

  +-------------------------------------------------------------------------+
  | <exp1>  <exp2> |  <exp1> xor <exp2>   <bit1> <bit2> | <bit1> xor <bit2> |
  |----------------+------------------------------------+-------------------|
  | FALSE   FALSE  |        FALSE           0      0    |         0         |
  | FALSE   TRUE   |        TRUE            0      1    |         1         |
  | TRUE    FALSE  |        TRUE            1      0    |         1         |
  | TRUE    TRUE   |        FALSE           1      1    |         0         |
  +-------------------------------------------------------------------------+

    For integer expressions, it does a bit-by-bit combination of the two
    integer values, using the right truth table above. The result is a
    sixteen-bit integer value.

      <bool exp>    any combination of Boolean values and operators.

      <int expr>    any combination of Integer values and operators.

  -------------------------------- Example ---------------------------------

           if (A = B) xor (A = C) then
             Writeln('A is either B or C but not both');

           I := $4123 xor $0F00;    { I = $4E23 }

See Also: and or not
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson