Unwise bit operations
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));
        }
    }