Difference between revisions of "And"
From Lazarus wiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
− | And produces a value of [[True|true]] if and only if both of its operands are true. | + | = Boolean operation = |
+ | |||
+ | '''And''' produces a value of [[True|true]] if and only if both of its operands are true. | ||
+ | |||
+ | == Truth table == | ||
+ | |||
+ | {| border="1" style="border: 1px solid; border-collapse: collapse;" | ||
+ | |- | ||
+ | !align=center| A !! align=center|B !! A and B | ||
+ | |- | ||
+ | | false || false | ||
+ | |style="background: #eeeeee" | false | ||
+ | |- | ||
+ | | false || true | ||
+ | |style="background: #eeeeee" | false | ||
+ | |- | ||
+ | | true || false | ||
+ | |style="background: #eeeeee" | false | ||
+ | |- | ||
+ | | true || true | ||
+ | |style="background: #eeeeee" | true | ||
+ | |} | ||
+ | |||
= Bitwise operation = | = Bitwise operation = |
Revision as of 10:44, 26 October 2007
Boolean operation
And produces a value of true if and only if both of its operands are true.
Truth table
A | B | A and B |
---|---|---|
false | false | false |
false | true | false |
true | false | false |
true | true | true |
Bitwise operation
Bitwise and sets a bit to 1 if and only if all of the corresponding bits in its operands are 1.
Clear a bit
<delphi> function ClearBit(const AValue, ABitNumber:integer):integer; begin
result := AValue and not(1 shl ABitNumber);
end; </delphi> If you call ClearBit(%1111,1) then get %1101 (%1111 = 15 and %1101 = 13). If you call ClearBit(13,2) then get 9 (9 = %1001) .