bitwiseor
bitwiseor() Function
Performs a bitwise 'or' operation of the number arguments by taking the binary representation of each of the numbers and performing the logical or operation on each of the bits.
Logical "or" Table
Bit1 | Bit2 | Result |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 1 | 1 |
Usage
<source lang="mtmacro" line> [h: val = bor(num, num, ...)] [h: val = btwiseor(num, num, ...)] </syntaxhighlight>
Examples
<source lang="mtmacro" line>
[r: bor(1,0)] </syntaxhighlight> Returns 1.
<source lang="mtmacro" line> [r: bor(1,1)] </syntaxhighlight> Returns 1.
<source lang="mtmacro" line> [r: bor(0,0)] </syntaxhighlight> Returns 0.
<source lang="mtmacro" line> [r: bor(2, 4] </syntaxhighlight> Returns 6. 2 in binary is 010 and 4 in binary is 100, so a bitwise or of these two values is 110 which is 6 in decimal.
<source lang="mtmacro" line> [r: band(20, 12)] </syntaxhighlight> Returns 4.
20 in binary is 10100 and 12 in binary is 01100, the bitwise 'and' of these values is 00100 in binary which is 4 in decimal.