[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bitwise logical operators
Date: Wed, 17 Jun 92 22:06:25 -0400
From: "Aubrey Jaffer" <firstname.lastname@example.org>
Date: Tue, 16 Jun 92 10:55:34 -0400
From: email@example.com (Jonathan Rees)
No machine dependencies here; the semantics isn't sensitive to word
size or integer representation. I'll supply portable definitions on
They are in SLIB as well.
Having said that there has been no objection, let me disrupt this
status quo and suggest some different names:
bitwise-and, bitwise-ior, bitwise-xor, bitwise-not, arithmetic-shift
These are what Richard Kelsey calls them. I've been using these names
for about a year now and like them better than the Common Lisp names.
They're more descriptive, and I would expect them to be easier for
beginners to cope with. And calling them "logical" implies that other
operations on integers are illogical.
These are fine with me.
Any opinions on logcount (bit-count) and integer-length?
I use INTEGER-LENGTH for gauging the size of integers, since LOG is
not an essential procedure and the number of bits is what I really
want anyway. LOGCOUNT seems useful for determining if a number is
exactly a power of 2.
(define power-of-two? (x) (= x (bitwise-and x (- x))))
But there are other reasons to want LOGCOUNT.