From WikiChip
Difference between revisions of "mirc/identifiers/$not"
< mirc‎ | identifiers

m
 
Line 1: Line 1:
{{mirc title|$not identifier}}'''$not''' returns the binary NOT of N as an unsigned 32-bit number.
+
{{mirc title|$not identifier}}'''$not''' returns the binary NOT of a number
  
  
 
== Synopsis ==
 
== Synopsis ==
<pre>$not(<N>)
+
<pre>$not(<N>)</pre>
</pre>
 
  
 
== Parameters ==
 
== Parameters ==
N = Base-10 Number in the range +/- 2^32-1
+
* '''N''' - the number, in base10/decimal
  
 
== Properties ==
 
== Properties ==
Line 35: Line 34:
 
; returns: 4294967290 is the signed representation of -6 so 5 is the same as 5
 
; returns: 4294967290 is the signed representation of -6 so 5 is the same as 5
 
</pre>
 
</pre>
 
<pre>
 
//var %n $calc(2^32 ) | echo -a $not(%n)
 
; returns 0 because N is too large
 
</pre>
 
 
  
 
<pre>
 
<pre>

Latest revision as of 13:10, 30 October 2017

$not returns the binary NOT of a number


Synopsis[edit]

$not(<N>)

Parameters[edit]

  • N - the number, in base10/decimal

Properties[edit]

None

Example[edit]

$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:

  1. 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.
  2. Flip each 0-bit to 1, and each 1-bit to 0
  3. 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
; 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[edit]

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[edit]

[Expand]
v · d · e mIRC identifier list