# 2d: bit logic ### `++con` Binary OR Computes the bit-wise logical OR of two [atom]()s, `a` and `b`, producing an atom. Accepts ------- `a` is an atom `b` is an atom Produces -------- An atom. Source ------ ++ con :: binary or ~/ %con |= {a/@ b/@} =+ [c=0 d=0] |- ^- @ ?: ?&(=(0 a) =(0 b)) d %= $ a (rsh 0 1 a) b (rsh 0 1 b) c +(c) d %+ add d %^ lsh 0 c ?& =(0 (end 0 1 a)) =(0 (end 0 1 b)) == == Examples -------- > (con 0b0 0b1) 1 > (con 0 1) 1 > (con 0 0) 0 > `@ub`(con 0b1111.0000 0b1.0011) 0b1111.0011 > (con 4 4) 4 > (con 10.000 234) 10.234 *** ### `++dis` Binary AND Computes the bit-wise logical AND of two atoms `a` and `b`, producing an atom. Accepts ------- `a` is an atom. `b` is an atom. Produces -------- An atom. Source ------ ++ dis :: binary and ~/ %dis |= {a/@ b/@} =| {c/@ d/@} |- ^- @ ?: ?|(=(0 a) =(0 b)) d %= $ a (rsh 0 1 a) b (rsh 0 1 b) c +(c) d %+ add d %^ lsh 0 c ?| =(0 (end 0 1 a)) =(0 (end 0 1 b)) == == Examples -------- > `@ub`9 0b1001 > `@ub`5 0b101 > `@ub`(dis 9 5) 0b1 > (dis 9 5) 1 > `@ub`534 0b10.0001.0110 > `@ub`987 0b11.1101.1011 > `@ub`(dis 534 987) 0b10.0001.0010 > (dis 534 987) 530 *** ### `++mix` Binary XOR Produces the bit-wise logical XOR of `a` and `b`, producing an atom. Accepts ------- `a` is an atom `b` is an atom Produces -------- An atom. Source ------ ++ mix :: binary xor ~/ %mix |= {a/@ b/@} ^- @ =+ [c=0 d=0] |- ?: ?&(=(0 a) =(0 b)) d %= $ a (rsh 0 1 a) b (rsh 0 1 b) c +(c) d (add d (lsh 0 c =((end 0 1 a) (end 0 1 b)))) == Examples -------- > `@ub`2 0b10 > `@ub`3 0b11 > `@ub`(mix 2 3) 0b1 > (mix 2 3) 1 > `@ub`(mix 2 2) 0b0 > (mix 2 2) 0 *** ### `++not` Binary NOT Computes the bit-wise logical NOT of the bottom `b` blocks of size `a` of `c`. Accepts ------- `a` is a block size (see `++bloq`). `b` is an atom. `c` is an atom. Produces -------- An atom. Source ------ ++ not |= {a/bloq b/@ c/@} :: binary not (sized) (mix c (dec (bex (mul b (bex a))))) Examples -------- > `@ub`24 0b1.1000 > (not 0 5 24) 7 > `@ub`7 0b111 > (not 2 5 24) 1.048.551 > (not 2 5 1.048.551) 24 > (not 1 1 (not 1 1 10)) 10 ***