Or

From Free Pascal wiki
Revision as of 21:55, 25 October 2007 by Djzepi (talk | contribs) (New page: Or produces a value of true if some value is true and false if both of its operands are false. = Bitwise operation = Bitwise or sets the bit to 1 if one corresponding...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Or produces a value of true if some value is true and false if both of its operands are false.


Bitwise operation

Bitwise or sets the bit to 1 if one corresponding bits in its operands are 1, and to 0 if they all are 0.

<delphi> function SetBit(const AValue, ABitNumber:integer):integer; begin

  result := AValue or (1 shl ABitNumber);

end; </delphi> If you call SetBit(%1000,1) then get %1010 (%1000 = 8 and %1010 = 10). If you call SetBit(10,2) then get 14 (14 = %1110). If you call SetBit(10,1) then get 10.

Read more