1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/f_bt_and.htm
2024-04-01 10:24:07 +02:00

112 lines
9 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Function BIT-AND, BIT-ANDC1, BIT-ANDC2...</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="f_bt_sb.htm">
<LINK REL=UP HREF="c_arrays.htm">
<LINK REL=NEXT HREF="f_bt_vec.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="f_bt_sb.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_arrays.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="f_bt_vec.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="bit-and"><A NAME="bit-andc1"><A NAME="bit-andc2"><A NAME="bit-eqv"><A NAME="bit-ior"><A NAME="bit-nand"><A NAME="bit-nor"><A NAME="bit-not"><A NAME="bit-orc1"><A NAME="bit-orc2"><A NAME="bit-xor"><I>Function</I> <B>BIT-AND, BIT-ANDC1, BIT-ANDC2, BIT-EQV, BIT-IOR, BIT-NAND, BIT-NOR, BIT-NOT, BIT-ORC1, BIT-ORC2, BIT-XOR</B></A></A></A></A></A></A></A></A></A></A></A> <P>
<P><B>Syntax:</B><P>
<P>
<B>bit-and</B> <I>bit-array1 bit-array2 </I><TT>&amp;optional</TT><I> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<B>bit-andc1</B> <I>bit-array1 bit-array2 </I><TT>&amp;optional</TT><I> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<B>bit-andc2</B> <I>bit-array1 bit-array2 </I><TT>&amp;optional</TT><I> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<B>bit-eqv</B> <I>bit-array1 bit-array2 </I><TT>&amp;optional</TT><I> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<B>bit-ior</B> <I>bit-array1 bit-array2 </I><TT>&amp;optional</TT><I> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<B>bit-nand</B> <I>bit-array1 bit-array2 </I><TT>&amp;optional</TT><I> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<B>bit-nor</B> <I>bit-array1 bit-array2 </I><TT>&amp;optional</TT><I> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<B>bit-orc1</B> <I>bit-array1 bit-array2 </I><TT>&amp;optional</TT><I> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<B>bit-orc2</B> <I>bit-array1 bit-array2 </I><TT>&amp;optional</TT><I> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<B>bit-xor</B> <I>bit-array1 bit-array2 </I><TT>&amp;optional</TT><I> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<P>
<B>bit-not</B> <I>bit-array <TT>&amp;optional</TT> opt-arg</I> =&gt; <I>resulting-bit-array</I><P>
<P>
<P><B>Arguments and Values:</B><P>
<P>
<I>bit-array</I>, <I>bit-array1</I>, <I>bit-array2</I>---a <A REL=DEFINITION HREF="26_glo_b.htm#bit_array"><I>bit array</I></A>. <P>
<I>Opt-arg</I>---a <A REL=DEFINITION HREF="26_glo_b.htm#bit_array"><I>bit array</I></A>, or <A REL=DEFINITION HREF="a_t.htm#t"><B>t</B></A>, or <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. The default is <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
<I>Bit-array</I>, <I>bit-array1</I>, <I>bit-array2</I>, and <I>opt-arg</I> (if an <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>array</I></A>) must all be of the same <A REL=DEFINITION HREF="26_glo_r.htm#rank"><I>rank</I></A> and <A REL=DEFINITION HREF="26_glo_d.htm#dimension"><I>dimensions</I></A>. <P>
<I>resulting-bit-array</I>---a <A REL=DEFINITION HREF="26_glo_b.htm#bit_array"><I>bit array</I></A>. <P>
<P><B>Description:</B><P>
<P>
These functions perform bit-wise logical operations on <I>bit-array1</I> and <I>bit-array2</I> and return an <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>array</I></A> of matching <A REL=DEFINITION HREF="26_glo_r.htm#rank"><I>rank</I></A> and <A REL=DEFINITION HREF="26_glo_d.htm#dimension"><I>dimensions</I></A>, such that any given bit of the result is produced by operating on corresponding bits from each of the arguments. <P>
In the case of <A REL=DEFINITION HREF="#bit-not"><B>bit-not</B></A>, an <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>array</I></A> of <A REL=DEFINITION HREF="26_glo_r.htm#rank"><I>rank</I></A> and <A REL=DEFINITION HREF="26_glo_d.htm#dimension"><I>dimensions</I></A> matching <I>bit-array</I> is returned that contains a copy of <I>bit-array</I> with all the bits inverted. <P>
If <I>opt-arg</I> is of type <TT>(array bit)</TT> the contents of the result are destructively placed into <I>opt-arg</I>. If <I>opt-arg</I> is the symbol <A REL=DEFINITION HREF="a_t.htm#t"><B>t</B></A>, <I>bit-array</I> or <I>bit-array1</I> is replaced with the result; if <I>opt-arg</I> is <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A> or omitted, a new <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>array</I></A> is created to contain the result. <P>
The next figure indicates the logical operation performed by each of the <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>functions</I></A>. <P>
<PRE>
Function Operation
----------
<A REL=DEFINITION HREF="#bit-and">bit-and</A> and
<A REL=DEFINITION HREF="#bit-eqv">bit-eqv</A> equivalence (exclusive nor)
<A REL=DEFINITION HREF="#bit-not">bit-not</A> complement
<A REL=DEFINITION HREF="#bit-ior">bit-ior</A> inclusive or
<A REL=DEFINITION HREF="#bit-xor">bit-xor</A> exclusive or
<A REL=DEFINITION HREF="#bit-nand">bit-nand</A> complement of bit-array1 and bit-array2
<A REL=DEFINITION HREF="#bit-nor">bit-nor</A> complement of bit-array1 or bit-array2
<A REL=DEFINITION HREF="#bit-andc1">bit-andc1</A> and complement of bit-array1 with bit-array2
<A REL=DEFINITION HREF="#bit-andc2">bit-andc2</A> and bit-array1 with complement of bit-array2
<A REL=DEFINITION HREF="#bit-orc1">bit-orc1</A> or complement of bit-array1 with bit-array2
<A REL=DEFINITION HREF="#bit-orc2">bit-orc2</A> or bit-array1 with complement of bit-array2
Figure 15-4. Bit-wise Logical Operations on Bit Arrays
</PRE>
<P>
<P><B>Examples:</B><P>
<PRE>
(bit-and (setq ba #*11101010) #*01101011) =&gt; #*01101010
(bit-and #*1100 #*1010) =&gt; #*1000
(bit-andc1 #*1100 #*1010) =&gt; #*0010
(setq rba (bit-andc2 ba #*00110011 t)) =&gt; #*11001000
(eq rba ba) =&gt; <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
(bit-not (setq ba #*11101010)) =&gt; #*00010101
(setq rba (bit-not ba
(setq tba (make-array 8
:element-type 'bit))))
=&gt; #*00010101
(equal rba tba) =&gt; <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
(bit-xor #*1100 #*1010) =&gt; #*0110
</PRE>
</TT> <P>
<P><B>Affected By:</B> None.
<P>
<P><B>Exceptional Situations:</B> None.
<P>
<P><B>See Also:</B><P>
<P>
<A REL=DEFINITION HREF="f_logand.htm#lognot"><B>lognot</B></A>, <A REL=DEFINITION HREF="f_logand.htm#logand"><B>logand</B></A> <P>
<P><B>Notes:</B> None.
<P>
<HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>