From WikiChip
Difference between revisions of "mirc/identifiers/$not"
m |
|||
Line 1: | Line 1: | ||
− | {{mirc title|$not | + | {{mirc title|$not identifier}}'''$not''' returns the binary NOT of N as an unsigned 32-bit number. |
− | '''$not''' returns the binary NOT of N as an unsigned 32-bit number. | + | |
== Synopsis == | == Synopsis == | ||
<pre>$not(<N>) | <pre>$not(<N>) | ||
</pre> | </pre> | ||
+ | |||
== Parameters == | == Parameters == | ||
N = Base-10 Number in the range +/- 2^32-1 | N = Base-10 Number in the range +/- 2^32-1 | ||
== Properties == | == Properties == | ||
− | |||
None | None | ||
== Example == | == 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<br /> | |
− | |||
<pre>//var %n 5 | echo -a $not(%n) $base($not(%n),10,16) | <pre>//var %n 5 | echo -a $not(%n) $base($not(%n),10,16) | ||
Line 60: | Line 59: | ||
* [[List of identifiers - mIRC]] | * [[List of identifiers - mIRC]] | ||
{{mIRC identifier list}} | {{mIRC identifier list}} | ||
+ | [[Category:mIRC identifiers|not]] |
Revision as of 06:46, 21 September 2017
Commands & Identifiers
Basics
Events
Matching Tools
Data Storage
Control Structures
GUI Scripting
Sockets
Advanced Scripting
Additional Resources
Security
Other
$not 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