In my experience it's easier to convert it to a polynomial when calculating by hand, especially when there're a lot of zeroes.
1010 = 1*x^3 + 0*x^2 + 1*x^1 + 0*x^0 = x^3 + x = x3 + x
101101000 = x8 + x6 + x5 + x3
-------------------
x3 + x ) x8 + x6 + x5 + x3
Then you divide the largest term in the dividend (x^8
) with the first term in the divisor (x^3
), resulting in x^5
. You put that number on top and then multiply it with each term in the divisor. This yields the following for the first iteration:
x5
-------------------
x3 + x ) x8 + x6 + x5 + x3
x8 + x6
Doing XOR for each term then yields the new dividend: x5 + x3
:
x5
-------------------
x3 + x ) x8 + x6 + x5 + x3
x8 + x6
-------------------
x5 + x3
Follow the same pattern until the dividend's largest term is smaller then the divisor's largest term. After the calculations are complete it will look like this:
x5 + x2
-------------------
x3 + x ) x8 + x6 + x5 + x3
x8 + x6
-------------------
x5 + x3
x5 + x3
-------------------
0
The reminder in this case is 0, which would indicate that most likely no errors has occurred during the transmission.
Note: I've shortened x^y
as xy
in the example above to reduce the clutter in the answer, since SO doesn't support math equation formatting.
Note2: Adding/subtracting a multiple of the divisor from the dividend will also give the reminder 0, since (P(x) + a*C(x)) / C(x) = P(x)/C(x) + a*C(x)/C(x)
gives the same reminder as P(x)/C(x)
since the reminder of a*C(x)/C(x)
is 0.