From WikiChip
Difference between revisions of "mirc/identifiers/$not"
Maroonbells (talk | contribs) (Create content for empty page) |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | ''' | + | {{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 | + | * '''N''' - the number, in base10/decimal |
== 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 24: | Line 23: | ||
# 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 | ||
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> | <pre> | ||
; mIRC doesn't have the $neg function, but if it did, $not(N) would be $neg(N) less 1. | ; mIRC doesn't have the $neg function, but if it did, $not(N) would be $neg(N) less 1. | ||
− | //var %n 5 | echo - | + | //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)) |
</pre> | </pre> | ||
Line 59: | Line 52: | ||
* [[List of identifiers - mIRC]] | * [[List of identifiers - mIRC]] | ||
{{mIRC identifier list}} | {{mIRC identifier list}} | ||
+ | [[Category:mIRC identifiers|not]] |
Latest revision as of 12:10, 30 October 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 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:
- 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
; 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]
mIRC identifier list