Copie du wikimiroir

Ceci est un miroir du wiki de pascal.chat. La modification, l’historique et la connexion se trouvent là-bas.

Xor/fr

Deutsch · English · Français · Suomi · Русский

Opération booléenne

Le Ou exclusif (xor) vaut true si et seulement une opérande exactement vaut true. Dit autrement, l'opérateur vaut true si les deux opérandes ont des valeurs de vérité différentes.

Table de vérité

A B A xor B
  false     false     false
  false   true   true
  true   false   true
  true   true   false

Opération bit à bit

Le xot bit à bit met le bit à 1 si les bits opérandes correspondants sont différents, et vaut sinon.

Inverser un bit

pascal
function ToggleBit(const AValue,ABitNumber:integer):integer;
begin
   result := AValue xor 1 shl ABitNumber;
end;

Si vous appelez ToggleBit(11,0), vous obtenez 10. Si vous appelez ToggleBit(10,2) alors vous obtenez 14.

Voir aussi


From the Free Pascal wiki, page "Xor/fr", as it stood on 2020-03-03 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Version 1, dernière modification par WikiArchive .