Here's how to calculate the CRC code for a given bitstring (ex. 1100):
First of all, for hand computation at least, bitstrings are represented by polynomials with binary coefficients. The data we want to create a CRC code for is referred to as the information polynomial:
i(x) = ik-1xk-1 + ik-2xk-2 + ... + i1x + i0 for k bits
For the example bitstring 1100,
i(x) = (1)x3 + (1)x2 + (0)x1 + (0)x0
= x3 + x2
Next, you need an appropriate generator polynomial g(x), which can be obtained from a standardized list of polynomial codes (i.e. CRC-8, CRC-16, CRC-32, etc.). Generator polynomials are generally chosen for their error detecting capability, but it is considered to be a black art by mere mortals and trying to make your own is probably a very bad idea (unless you're a mathematician).
So for this example, we'll arbitrarily choose
g(x) = x3 + x + 1
Now that we have both our generator and information polynomials, we can begin our actual CRC calculation.
Step 1: Multiply i(x) by the highest-order term in g(x) to shift the bitstring the right number of bits to the left in order to make room for the CRC code which will be appended to it.
x3i(x) = x3(x3 + x2) = x6 + x5
So now our bitstring looks like: 1100000 (since, as implied by g(x), we will be generating 3 CRC bits after i(x)).
Step 2: Divide the product obtained in Step 1 by g(x). The remainder is our CRC string.
Recall modulo-2 arithmetic: 0+0=0, 0+1=1, 1+0=1, 1+1=0 (no carries)
x3 + x2 + x
_______________
x3 + x + 1 ) x6 + x5
x6 + + x4 + x3
-----------------
x5 + x4 + x3
x5 + x3 + x2
-----------------
x4 + x2
x4 + x2 + x
----------------
x
Remainder r(x) = x = 010 (we don't care about the quotient)
Therefore, the final transmitted codeword is:
b(x) = x3i(x) + r(x) = x6 + x5 + x = 1100010
where bits b6 ... b3 (1100) represent our data and bits b2 ... b0 (010) represent the corresponding CRC code.
And there you have it! Is that neat or what?
REFERENCES
Leon-Garcia and Widjaja. Communication Networks. McGraw Hill, 2000.