Node:xor, Previous:WriteStr, Up:Reference
operator xor (operand1, operand2: Boolean) = Result: Boolean;or
operator xor (operand1, operand2: integer_type) = Result: integer_type;or
procedure xor (var operand1: integer_type; operand2: integer_type);
In GNU Pascal, xor has three built-in meanings:
Boolean-type
expressions. The result of the operation is of Boolean type.
(Logical foo xor bar in fact has the same effect as
foo <> bar.)
operand1 is "xor"ed bitwise with
operand2; the result is stored in operand1.
ISO Pascal does not define the xor operator;
Borland Pascal and Delphi do.
Use of xor as a "procedure" is a GNU Pascal extension.
program XorDemo;
var
a, b, c: Integer;
begin
if (a = 0) xor (b = 0) then
c := 1 { happens if either `a' or `b' is zero, }
{ but not if both are zero or both nonzero }
else if (a xor b) = 0 then { bitwise xor }
c := 2 { happens if a = b }
else
xor (c, a) { same as `c := c xor a' }
end.