Sign in Join
Wiki copytemporary

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.

Revision 1, last changed by WikiArchive .

Edited on wiki.freepascal.org by 2 people, 2016–2020

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
E-ricCreated page
TrevFixed syntax highlighting (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.