1.4.6 Bitwise Operations
Multiplies x by 2^y. This is equivalent to shifting the binary representation of x to the left by y bits.
Bitwise logical operations on numbers. These forms compute the bitwise AND, inclusive OR, exclusive OR, and equivalence (a.k.a. exclusive NOR), respectively. These macros expand into calls of binary functions such as binary-logand, binary-logior, etc. The guards of these functions require that all inputs be integers. When passed one argument, these functions return the argument unchanged. When passed no arguments, logand and logeqv return -1, while logior and logxor return 0.
Examples: |
> (logand) |
-1 |
> (logior) |
0 |
> (logxor) |
0 |
> (logeqv) |
-1 |
> (logand 1) |
1 |
> (logand 10 6) |
2 |
> (logior 10 5) |
15 |
> (logxor 15 9) |
6 |
> (logeqv 5 6) |
-4 |
> (logior "5") |
"5" |
Computes the bitwise logical NAND of the two given numbers.
Example: |
> (lognand 10 6) |
-3 |
Computes the bitwise logical NOR of x and y.
Example: |
> (lognor 10 6) |
-15 |
Computes the bitwise logical NOT of the given number.
Example: |
> (lognot 5) |
-6 |
Returns the ith bit in the two’s complement binary representation of j.
Returns the number of "on" bits in the binary representation of x.
Computes the bitwise logical Inclusive OR of y with the bitwise logical NOT of x.
Example: |
> (logorc1 10 6) |
-9 |
Computes the bitwise logical Inclusive OR of x with the bitwise logical NOT of y.
Example: |
> (logorc2 10 6) |
-5 |
Returns true if and only if x and y share a ’1’ bit somewhere in their binary representation (i.e. (logand x y) is not zero).