Sign in Join
Wiki copytemporary

Xor/fi: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Xor/fi

OldNewLine
1+# Xor boolean lausekkeessa
2+
3+Exclusive or (**xor**) eli eri- operaation tuloksena on [[True|true]] jos ainostaan toinen operandeista on true (tosi).
4+
5+## Totuustaulukko
6+
7+| A | B |   A xor B   |
8+|:---------:|:---------:|-------------|
9+|   false   |   false   |   false |
10+|   false |   true |   true |
11+|   true |   false |   true |
12+|   true |   true |   false |
13+
14+# Xor bittikohtaisissa toiminnoissa
15+
16+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.
17+
18+## Vaihda bitin arvo
19+
20+``` pascal
21+function ToggleBit(const AValue,ABitNumber:integer):integer;
22+begin
23+ result := AValue xor 1 shl ABitNumber;
24+end;
25+```
26+
27+Jos kutsut funktiota ToggleBit(11,0) niin funktio palauttaa arvon 10. Jos kutsu on ToggleBit(10,2) niin palautettava arvo on 14.
28+
29+### Lisätietoja
30+
31+- [[Variable parameter|XOR swap]]
32+- [[Shl]]
33+- [[Const/fi|Const]]
34+- [[Function]]
35+- [[Integer/fi|Integer]]
36+
37+---
38+*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](/wiki-contact).*

Back to history