Difference between revisions of "Or"
From Lazarus wiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
− | Or produces a value of [[True|true]] if some value is true and [[False|false]] if both of its operands are false. | + | = Boolean operation = |
+ | |||
+ | '''Or''' produces a value of [[True|true]] if some value is true and [[False|false]] if both of its operands are false. | ||
+ | |||
+ | == Truth table == | ||
+ | |||
+ | {| border="1" style="border: 1px solid; border-collapse: collapse;" | ||
+ | |- | ||
+ | !align=center| A !! align=center|B !! A or B | ||
+ | |- | ||
+ | | false || false | ||
+ | |style="background: #dddddd" | false | ||
+ | |- | ||
+ | | false || true | ||
+ | |style="background: #dddddd" | true | ||
+ | |- | ||
+ | | true || false | ||
+ | |style="background: #dddddd" | true | ||
+ | |- | ||
+ | | true || true | ||
+ | |style="background: #dddddd" | true | ||
+ | |} | ||
Revision as of 10:21, 26 October 2007
Boolean operation
Or produces a value of true if some value is true and false if both of its operands are false.
Truth table
A | B | A or B |
---|---|---|
false | false | false |
false | true | true |
true | false | true |
true | true | true |
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.
Set a bit
<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.