Tema: comando xor
Ver Mensaje Individual
  #3  
Antiguo 19-06-2012
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.670
Reputación: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
Sólo tienes que pulsar F1-Ayuda y te sale el mensaje explicándolo

Aquí un ejemplo:

Código Delphi [-]
var
  num1, num2, num3 : Integer;
  letter           : Char;

 begin
  num1   := $25;    // Binary value : 0010 0101   $25
  num2   := $32;    // Binary value : 0011 0010   $32
                    // XOr'ed value : 0001 0111 = $17
  letter := 'G';

  // And used to return a Boolean value
  if (num1 > 0) Xor (letter = 'G')
  then ShowMessage('Only one of the values is true')
  else ShowMessage('Both values are true or false');

  // And used to perform a mathematical Xor operation
  num3 := num1 Xor num2;

  // Display the result
  ShowMessageFmt('$25 Xor $32 = $%x',[num3]);
 end;

Cita:
The Xor keyword is used in two different ways:

1. To perform a logical or boolean 'Exclusive-or' of two logical values. If they are different, then the result is true.

2. To perform a mathematical 'Exclusive-or' of two integers. The result is a bitwise 'Exclusive-or' of the two numbers. For example:

10110001 Xor 01100110 = 11010111
Como ves, 1 xor 0 es 1, 0 xor 1 es 1, 0 xor 0 es 0 y 1 xor 1 es 1.

Responder Con Cita