Xor/fi
Deutsch · English · Français · Suomi · Русский
Xor boolean lausekkeessa
Exclusive or (xor) eli eri- operaation tuloksena on true jos ainostaan toinen operandeista on true (tosi).
Totuustaulukko
| A | B | A xor B |
|---|---|---|
| false | false | false |
| false | true | true |
| true | false | true |
| true | true | false |
Xor bittikohtaisissa toiminnoissa
Bitettäin tehtävä xor asettaa kyseisen bitin ykköseksi (1) jos vastaavat bitit eivät ole samoja ja nollaksi (0) jos ne ovat samoja.
Vaihda bitin arvo
function ToggleBit(const AValue,ABitNumber:integer):integer;
begin
result := AValue xor 1 shl ABitNumber;
end;Jos kutsut funktiota ToggleBit(11,0) niin funktio palauttaa arvon 10. Jos kutsu on ToggleBit(10,2) niin palautettava arvo on 14.
Lisätietoja
From the Free Pascal wiki, page "Xor/fi", 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.