Nim (537)(490)
Nim Compiler 0.10.2
I've been looking for a reason to learn nim so here we go.
For code golf, I have leveraged variable parameters and implicit returns. The variable parameters, per the documentation are less stack efficient. Personally, I find the implicit returns harder to read and would probably only use them in trivial procedures.
As for the algorithms, they are simple enough. For all operations except NOT, we compare each bit and manually compare them to our expected truth table. Set each bit as needed along the way in our output variable. In Nim, result is the implicit return value.
I wasn't sure if we were allowed to use built-in OR and AND for asserting two boolean conditions so the notZero procedure was put in their place.
proc s(x, y, b: var int)= x = x div 2 y = y div 2 b *= 2 proc n(x: var int): int = return -(x+1) proc a(x, y: var int): int = var b = 1 while x > 0 and y > 0: if (x mod 2 + y mod 2) == 2: result += b s(x,y,b) proc o(x, y: var int): int = var b = 1 while x + y > 0: if (x mod 2 + y mod 2) >= 1: result += b s(x,y,b) proc r(x, y: var int): int = var b = 1 while x + y > 0: if (x mod 2 + y mod 2) == 1: result += b s(x,y,b) Still looking for a better method...
Here is the non-squished version plus full test harness to run on your own machine.
If you just want to run a couple of inputs, here is test case lite.