bitwisenot: 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 'not' operation of the {number}. A bitwise not is performed by taking the binary representation of the {number} and performing a logical 'not' operation on each of these bits. | |name=bitwisenot | ||
|description=Performs a bitwise 'not' operation of the {number}. A bitwise not is performed by taking the binary representation of the {number} and performing a logical 'not' operation on each of these bits. | |||
'''Logical "not" Table''' | '''Logical "not" Table''' | ||
{ | {{{!}} | ||
{{!}}Bit {{!}}{{!}} Result | |||
{{!}}- | |||
{{!}}align=center{{!}} 0 {{!}}{{!}} align=center{{!}} 1 | |||
{{!}}- | |||
{{!}}align=center{{!}} 1 {{!}}{{!}} align=center{{!}} 0 | |||
{{!}}} | |||
Line 24: | Line 25: | ||
If you are unsure why the results are negative then you can get more information by reading [[wp:Twos_complement|Twos_complement]] | If you are unsure why the results are negative then you can get more information by reading [[wp:Twos_complement|Twos_complement]] | ||
|usage= | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: val = bnot(num)] | [h: val = bnot(num)] | ||
Line 31: | Line 31: | ||
</source> | </source> | ||
|examples= | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[bnot(1)] | [bnot(1)] | ||
Line 46: | Line 46: | ||
</source> | </source> | ||
Returns -13. | Returns -13. | ||
}} | |||
[[Category:Logical Function]] |
Revision as of 23:20, 6 March 2009
bitwisenot() Function
Performs a bitwise 'not' operation of the {number}. A bitwise not is performed by taking the binary representation of the {number} and performing a logical 'not' operation on each of these bits.
Logical "not" Table
Bit | Result |
0 | 1 |
1 | 0 |
Unfortunately its not quite as simple as the table above makes it appear since number are a string of 32 (or more bits) so a 1 in binary is actually a 00000000000000000000000000000001 and a 0 is actually a 00000000000000000000000000000000 so the table is now.
bnot of binary 00000000000000000000000000000000 is 11111111111111111111111111111111 which is -1 in decimal
bnot of binary 00000000000000000000000000000001 is 11111111111111111111111111111110 which is -2 in decimalIf you are unsure why the results are negative then you can get more information by reading Twos_complement
Usage
[h: val = bnot(num)]
[h: val = bitwisenot(num)]
Examples
[bnot(1)]
Returns 0.
[r: bnot(1)]
Returns 0.
[r: bnot(12]