Bdot


b.
Implements Bitwise Operations
initial writing: 2001-11-22
last updated: 2004-10-26



The adverb m b. has been extended to compute
bitwise functions on integer arguments. An argument atom
is treated as a list of length w of bits, where w
is the word size of the underlying machine. m=16+k specifies
the boolean function whose ravelled function table
is #:k .
For example, 17 b. specifies
bitwise and
(17 16+1
16+#.0 0 0 1).
There is special code to effect efficient
execution of the following cases:

  m b."r   monad and dyad
  m b./   monad and dyad
  m b./   monad
  m b./.   monad



Finally, 32 b. specifies rotate, 33 b.
specifies shift, and 34 b. specifies signed shift.


See also the
b. entry in the dictionary.


Examples:

   12345 (17 b.) 67890           bitwise and
48
   f=: (32#2)&#: { '.x'"_
   f 12345 67890 48
..................xx......xxx..x
...............x....x..x..xx..x.
..........................xx....
   _12345 (23 b.) 67890          bitwise or
_12297
   f _12345 67890 _12297
xxxxxxxxxxxxxxxxxx..xxxxxx...xxx
...............x....x..x..xx..x.
xxxxxxxxxxxxxxxxxx..xxxxxxxx.xxx
   20 b./~ i.10                  bitwise less than table
0 1 2 3 4 5 6 7 8 9
0 0 2 2 4 4 6 6 8 8
0 1 0 1 4 5 4 5 8 9
0 0 0 0 4 4 4 4 8 8
0 1 2 3 0 1 2 3 8 9
0 0 2 2 0 0 2 2 8 8
0 1 0 1 0 1 0 1 8 9
0 0 0 0 0 0 0 0 8 8
0 1 2 3 4 5 6 7 0 1
0 0 2 2 4 4 6 6 0 0
   23 b./ 2^i.10                cumulative bitwise or
1 3 7 15 31 63 127 255 511 1023
   _5 (33 b.) 12345              shift
385
   f 12345 385   
..................xx......xxx..x
.......................xx......x
   _5 (33 b.) _12345              shift
134217342
   f _12345 134217342
xxxxxxxxxxxxxxxxxx..xxxxxx...xxx
.....xxxxxxxxxxxxxxxxxx..xxxxxx.
   _5 (34 b.) _12345              signed shift
_386
   f _12345 _386
xxxxxxxxxxxxxxxxxx..xxxxxx...xxx
xxxxxxxxxxxxxxxxxxxxxxx..xxxxxx.