And/fi
Deutsch · English · Español · Français · Suomi · Русский
category:SuomiAnd (ja) boolean lausekkeessa
And eli ja -operaatio antaa true eli tosi arvon vain silloin kun molemmat operandit ovat tosia (true). Muissa tapauksissa tuloksena on epätosi eli false.
And eli ja-operaation totuustaulukko
| A | B | A and B (eli A ja B) |
|---|---|---|
| false | false | false |
| false | true | false |
| true | false | false |
| true | true | true |
And eli ja bittikohtaisissa toiminnoissa
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).
Onko kakkosen potenssi
function IsPowerOfTwo( const aValue : longint ): boolean;
var
x : longint;
b : boolean;
begin
b := false;
if aValue <> 0 then
begin
x := aValue - 1;
x := x and aValue;
if x = 0 then b := true;
end;
result := b;
end;Jos kutsutaan IsPowerOfTwo(4) niin saadaan true. Jos kutsutaan IsPowerOfTwo(5) niin saadaan false .
Lisätietoa
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.