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

(Example)
m (Changed to an example that didn't return zero)
Line 13: Line 13:
  
 
== Example ==
 
== Example ==
<source lang="mIRC">//echo -a $and(7,32)</source>
+
<source lang="mIRC">//echo -a $and(14,27)
Would display "0", only bit which are both 1 gives 1, otherwise it gives 0
+
; returns 10
<pre>7 is in  binary: 000111
+
</source>
                &         
+
 
32 is in binary: 100000
+
Only bits which are both 1 return 1, otherwise the bit is 0
               
+
 
                000000
+
<pre>//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.
 
</pre>
 
</pre>
  

Revision as of 15:08, 12 June 2017

$and returns the AND operation of the two numbers, the numbers are decimal not binary.

Synopsis

$addtok(<A>,<B>)

Paramters

  • <A> - The first number
  • <B> - The second number

Properties

None

Example

//echo -a $and(14,27)
; returns 10

Only bits which are both 1 return 1, otherwise the bit is 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

$not $or $xor $biton $bitoff $isbit