From WikiChip
Difference between revisions of "mirc/identifiers/$not"
Maroonbells (talk | contribs) m |
Maroonbells (talk | contribs) m |
||
Line 24: | Line 24: | ||
# Convert the answer from binary to base 10. | # Convert the answer from binary to base 10. | ||
− | <pre>//var %n 5 | echo -a $base(%n,10,2,32) | echo -a $str(-,32) | echo -a $base($not( | + | <pre>//var %n 5 | echo -a $base(%n,10,2,32) | echo -a $str(-,32) | echo -a $base($not(%n),10,2,32) |
; returns: | ; returns: | ||
00000000000000000000000000000101 | 00000000000000000000000000000101 |
Revision as of 19:19, 14 June 2017
Returns the binary NOT of N as an unsigned 32-bit number
Synopsis
$not(<N>)
Parameters
N = Base-10 Number in the range +/- 2^32-1
Properties
None
Example
NOT returns the binary NOT of <N>. It returns 0 if the bit is 1, and returns 1 if the bit is 0. In effect, every 1-bit in the result toggles the 0/1 state of the corresponding bit of the input number
//var %n 5 | echo -a $not(%n) $base($not(%n),10,16) ; 4294967290 FFFFFFFA
Here's how the answer was calculated:
- Convert base-10 N to binary. If N is negative, treat as if a signed 32-bit number where the leftmost bit is a 1.
- Flip each 0-bit to 1, and each 1-bit to 0
- Convert the answer from binary to base 10.
//var %n 5 | echo -a $base(%n,10,2,32) | echo -a $str(-,32) | echo -a $base($not(%n),10,2,32) ; returns: 00000000000000000000000000000101 -------------------------------- 11111111111111111111111111111010
//var %n1 4294967290 | var %n2 -6 | echo -a %n1 is the signed representation of %n2 so $not(%n1) is the same as $not(%n2) ; returns: 4294967290 is the signed representation of -6 so 5 is the same as 5
//var %n $calc(2^32 ) | echo -a $not(%n) ; returns 0 because N is too large
; mIRC doesn't have the $neg function, but if it did, $not(N) would be $neg(N) less 1. //var %n 5 | echo -a $not(%n) is the same as $calc( -%n -1) so NOT of each is the same: $not($not(%n)) is the same as $not($calc( -%n -1))
Compatibility
Added: mIRC v5.61
Added on: 23 Sep 1999
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.
See also
mIRC identifier list