From WikiChip
Difference between revisions of "mirc/identifiers/$and"
Line 1: | Line 1: | ||
{{mirc title|$and identifier}}'''$and''' returns the AND operation of two numbers. | {{mirc title|$and identifier}}'''$and''' returns the AND operation of two numbers. | ||
+ | |||
+ | '''Note:''' The numbers need to be provided in decimal, and are then converted to binary, the AND operation applied, and the answer converted back to decimal. | ||
Line 14: | Line 16: | ||
<source lang="mIRC">//echo -a $and(14,27) | <source lang="mIRC">//echo -a $and(14,27) | ||
; returns 10 | ; returns 10 | ||
+ | ; 14 is 00001110 when converted to binary | ||
+ | ; 27 is 00011011 when converted to binary | ||
+ | ; AND 00001010 which is 10 when converted back to decimal | ||
</source> | </source> | ||
− | + | The AND operation returns a 1 when both matching binary bits are 1, otherwise returns 0 | |
<source lang="mIRC">//var %n1 14 | var %n2 27 | echo -a $base(%n1,10,2,8) | echo -a $base(%n2,10,2,8) | echo -a $str(-,8) | echo -a $base($and(%n1,%n2),10,2,8)</source> | <source lang="mIRC">//var %n1 14 | var %n2 27 | echo -a $base(%n1,10,2,8) | echo -a $base(%n2,10,2,8) | echo -a $str(-,8) | echo -a $base($and(%n1,%n2),10,2,8)</source> |
Revision as of 14:40, 30 October 2017
Commands & Identifiers
Basics
Events
Matching Tools
Data Storage
Control Structures
GUI Scripting
Sockets
Advanced Scripting
Additional Resources
Security
Other
$and returns the AND operation of two numbers.
Note: The numbers need to be provided in decimal, and are then converted to binary, the AND operation applied, and the answer converted back to decimal.
Synopsis
$and(<N1>,<N2>)
Parameters
- <N1>, <N2> - The numbers, in decimal
Properties
None
Example
//echo -a $and(14,27) ; returns 10 ; 14 is 00001110 when converted to binary ; 27 is 00011011 when converted to binary ; AND 00001010 which is 10 when converted back to decimal
The AND operation returns a 1 when both matching binary bits are 1, otherwise returns 0
//var %n1 14 | var %n2 27 | echo -a $base(%n1,10,2,8) | echo -a $base(%n2,10,2,8) | echo -a $str(-,8) | echo -a $base($and(%n1,%n2),10,2,8)
returns:
00001110 00011011 -------- 00001010
$and returns the answer as a decimal number, so the answer 10 is the decimal representation of binary 1010.
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