# Function LOGAND, LOGANDC1, LOGANDC2, LOGEQV, LOGIOR, LOGNAND, LOGNOR, LOGNOT, LOGORC1, LOGORC2, LOGXOR

### Syntax

logand `&rest` integersresult-integer logandc1 integer-1 integer-2result-integer logandc2 integer-1 integer-2result-integer logeqv `&rest` integersresult-integer logior `&rest` integersresult-integer lognand integer-1 integer-2result-integer lognor integer-1 integer-2result-integer lognot integerresult-integer logorc1 integer-1 integer-2result-integer logorc2 integer-1 integer-2result-integer logxor `&rest` integersresult-integer

### Description

The functions logandc1, arguments, that are treated as if they were binary. The table below lists the meaning of each of the functions. Where an `identity' is shown, it indicates the value yielded by the function when no arguments are supplied. ^ Function ^ Identity ^ Operation performed ^ | logandc1 | --- | and complement of integer-1 with integer-2 | | logandc2 | --- | and integer-1 with complement of integer-2 | | logand | `-1` | and | | logeqv | `-1` | equivalence (exclusive nor) | | logior | `0` | inclusive or | | lognand | --- | complement of integer-1 and integer-2 | | lognor | --- | complement of integer-1 or integer-2 | | lognot | --- | complement | | logorc1 | --- | or complement of integer-1 with integer-2 | | logorc2 | --- | or integer-1 with complement of integer-2 | | logxor | `0` | exclusive or | Negative integers are treated as if they were in two's-complement notation. ====Examples==== <blockquote> (logior 1 2 4 8) <r>15 </r> (logxor 1 3 7 15) <r>10 </r> (logeqv) <r>-1 </r> (logand 16 31) <r>16 </r> (lognot 0) <r>-1 </r> (lognot 1) <r>-2 </r> (lognot -1) <r>0 </r> (lognot (1+ (lognot 1000))) <r>999</r> </blockquote> In the following example, `m` is a mask. For each bit in the mask that is a `1`, the corresponding bits in `x` and `y` are exchanged. For each bit in the mask that is a `0`, the corresponding bits of `x` and `y` are left unchanged. <blockquote> (flet ((show (m x y) (format t "~%m = #o~6,'0O~%x = #o~6,'0O~%y = #o~6,'0O~%" m x y))) (let ((m #o007750) (x #o452576) (y #o317407)) (show m x y) (let ((z (logand (logxor x y) m))) (setf x (logxor z x)) (setf y (logxor z y)) (show m x y)))) <o>m = #o007750 x = #o452576 y = #o317407 m = #o007750 x = #o457426 y = #o312557 </o> <r>NIL </r> </blockquote> ====Side Effects==== None. ====Affected By==== None. ====Exceptional Situations==== Should signal type-error if any argument is not an integer. ====See Also==== * Function BOOLE ====Notes==== `(logbitp k -1)` returns true for all values of k. Because the following functions are not associative, they take exactly two arguments rather than any number of arguments. <blockquote> (lognand n1 n2) ≡ (lognot (logand n1 n2)) (lognor n1 n2) ≡ (lognot (logior n1 n2)) (logandc1 n1 n2) ≡ (logand (lognot n1) n2) (logandc2 n1 n2) ≡ (logand n1 (lognot n2)) (logiorc1 n1 n2) ≡ (logior (lognot n1) n2) (logiorc2 n1 n2) ≡ (logior n1 (lognot n2)) (logbitp j (lognot x)) ≡ (not (logbitp j x)) </blockquote>

### Page Tools
{"ft_lang_label":"__label__en","ft_lang_prob":0.6760972,"math_prob":0.89488596,"size":2931,"snap":"2019-26-2019-30","text_gpt3_token_len":982,"char_repetition_ratio":0.19405535,"word_repetition_ratio":0.05952381,"special_character_ratio":0.370522,"punctuation_ratio":0.045908183,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99050045,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-07-20T06:17:18Z\",\"WARC-Record-ID\":\"<urn:uuid:b741e496-3cfe-4450-a162-c378212c25a8>\",\"Content-Length\":\"28150\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:90a262cb-f3dd-4503-a97b-d0933ea37b1b>\",\"WARC-Concurrent-To\":\"<urn:uuid:6d2eb100-7828-4b37-b057-ed8844444442>\",\"WARC-IP-Address\":\"104.28.30.98\",\"WARC-Target-URI\":\"https://phoe.tymoon.eu/clus/doku.php?id=cl:functions:logand&redirect=1id=cl:functions:logxor\",\"WARC-Payload-Digest\":\"sha1:E355VV7PNNA5GX5RTAQ4YLA3UKMQSBIJ\",\"WARC-Block-Digest\":\"sha1:MDI2ZQ7BGOII5MUPYQRCMAOFM5SPKRXY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-30/CC-MAIN-2019-30_segments_1563195526446.61_warc_CC-MAIN-20190720045157-20190720071157-00315.warc.gz\"}"}