And

From Free Pascal wiki
Revision as of 10:44, 26 October 2007 by Djzepi (talk | contribs)
Jump to navigationJump to search

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) .

Read more