Unwise bit operations I like to golf in dc, but I'm sometimes frustrated because dc doesn't have bitwise operations.
Challenge
Provide four named functions which implement the equivalent of the c bitwise operations &amp;, |, ~ and ^ (bitwise AND, OR, NOT and XOR).  Each function will take two operands (~ takes only one) which are at least 32-bit unsigned integers.  Each function will return an unsigned integer of the same bit-width as the operands.
Restriction
You may only use operations that are supported by dc.  These are:

+ - * / Arithmetic addition, subtraction, multiplication and division
~ modulo (or divmod if your language supports it)
^ exponentiation
| modular exponentiation
v square root
&gt; &gt;= == != &lt;= &lt; standard equality/inequality operators
&gt;&gt; &lt;&lt; bit shift operators.  dc doesn't have these, but since they are trivially implemented in terms of division/multiplication by powers of 2, then I will allow these.

Control structures in dc my be clumsily built using (recursive) macros and (in)equality operations.  You may use whatever built-in control structures your language has.
You may also use logical operators &amp;&amp; || !, even though these aren't directly available in dc.
You must not use the bitwise operators &amp;, |, ~ and ^ or any functions that trivially implement them.
In addition you must not use built-in base-conversion-of-string operators or functions.

Please also consider providing a test program or online compiler snippet (not included in the golf score) to help verify your answer.
C, 134

The C preprocessor is pretty fun to abuse. Basically this macro defines the 3 functions, a, o, and x, for and, or, and xor respectively. The only difference in the algorithm for these operations is the criteria for setting the bit in the result. 

not is the function n. 

#define f(n,c)n(a,b){for(r=0,i=31;i+1;--i)if(((a&gt;&gt;i)%2+(b&gt;&gt;i)%2)c)r+=1&lt;&lt;i;return r;}
i,r;n(a){return 0xffffffff-a;}f(a,/2)f(o,)f(x,%2)


Tester program (takes a long time, I didn't spend any time optimizing it at all, but it does test every test case possible, beside MAX_INT related ones):

#define m_assert(expected, condition, actual)\
    if(!((expected) condition (actual)))\
        printf("assert fail @ line %i, expected: %x, actual %x, condition "#condition"\n", __LINE__, expected, actual);

int main()  {
    unsigned int j,k;
    for(j=0; j&lt;0xffff; ++j)    {
        m_assert(~j, ==, n(j));
        for(k=0; k&lt;0xffff; ++k)    {
            m_assert(j &amp; k, ==, a(j,k));
            m_assert(j | k, ==, o(j,k));
            m_assert(j ^ k, ==, x(j,k));
        }
    }