Sign in Join
Wiki copytemporary

And/fi: what changed

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

Title: And/fi

OldNewLine
1+# And (ja) boolean lausekkeessa
2+
3+**And** eli **ja** -operaatio antaa [[True|true]] eli tosi arvon vain silloin kun molemmat operandit ovat tosia (true). Muissa tapauksissa tuloksena on epätosi eli [[False|false]].
4+
5+## And eli ja-operaation totuustaulukko
6+
7+| A | B |   A and B (eli A ja B)   |
8+|:---------:|:---------:|--------------------------|
9+|   false   |   false   |   false |
10+|   false |   true |   false |
11+|   true |   false |   false |
12+|   true |   true |   true |
13+
14+# And eli ja bittikohtaisissa toiminnoissa
15+
16+Bitettäin tehtävä and (ja) asettaa kyseisen bitin ykköseksi (1) jos molemmat vastaavat bitit ovat ykkösiä (1). Muussa tapauksessa tulos on nolla (0).
17+
18+## Onko kakkosen potenssi
19+
20+``` pascal
21+function IsPowerOfTwo( const aValue : longint ): boolean;
22+var
23+ x : longint;
24+ b : boolean;
25+begin
26+ b := false;
27+ if aValue <> 0 then
28+ begin
29+ x := aValue - 1;
30+ x := x and aValue;
31+ if x = 0 then b := true;
32+ end;
33+ result := b;
34+end;
35+```
36+
37+Jos kutsutaan IsPowerOfTwo(4) niin saadaan true. Jos kutsutaan IsPowerOfTwo(5) niin saadaan false .
38+
39+### Lisätietoa
40+
41+- [[Not]]
42+- [[Shl]]
43+
44+- [[Const/fi|Const]]
45+- [[Function]]
46+- [[Integer/fi|Integer]]
47+
48+- [[Shl|Clear a bit]]
49+
50+---
51+*From the Free Pascal wiki, page "And/fi", as it stood on 2020-01-26 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).*
52+Category: Suomi

Back to history