bitwiseor: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Verisimilar (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
== | {{MacroFunction | ||
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. | |name=bitwiseor | ||
|description=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''' | '''Logical "or" Table''' | ||
{ | {{{!}} | ||
{{!}}Bit1 {{!}}{{!}} Bit2 {{!}}{{!}} Result | |||
{{!}}- | |||
{{!}}align=center{{!}} 0 {{!}}{{!}} align=center{{!}} 0 {{!}}{{!}} align=center{{!}} 0 | |||
{{!}}- | |||
{{!}}align=center{{!}} 0 {{!}}{{!}} align=center{{!}} 1 {{!}}{{!}} align=center{{!}} 1 | |||
{{!}}- | |||
{{!}}align=center{{!}} 1 {{!}}{{!}} align=center{{!}} 1 {{!}}{{!}} align=center{{!}} 1 | |||
{{!}}} | |||
|usage= | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: val = bor(num, num, ...)] | [h: val = bor(num, num, ...)] | ||
Line 20: | Line 20: | ||
</source> | </source> | ||
|examples= | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: bor(1,0)] | [r: bor(1,0)] | ||
Line 41: | Line 41: | ||
Returns 6. | 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. | 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> | <source lang="mtmacro" line> | ||
Line 49: | Line 47: | ||
Returns 4. | 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. | 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. | ||
}} | |||
[[Category:Logical Function]] |
Revision as of 23:25, 6 March 2009
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
[h: val = bor(num, num, ...)]
[h: val = btwiseor(num, num, ...)]
Examples
[r: bor(1,0)]
Returns 1.
[r: bor(1,1)]
Returns 1.
[r: bor(0,0)]
Returns 0.
[r: bor(2, 4]
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.
[r: band(20, 12)]
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.