Search code examples
matlabbinarybit-manipulationchecksumcrc32

MATLAB's gfdeconv vs. polynomial binary division


I've read A Painless Guide to CRC Error Detection Algorithms by Ross N. Williams where he uses binary division to get the remainder of the division of the original message 1101011011 and poly 10011. He arrives at a remainder of 1110.

I've been attempting to use MATLAB's gfdeconv with the above example. The description in the documentation says the function "divides polynomials over Galois field". I've entered the following into MATLAB:

[~, remd] = gfdeconv([1 1 0 1 0 1 1 0 1 1], [1 0 0 1 1]) 

However, I get a remainder of [0 0 1].

Am I missing something here? Why doesn't MATLAB's gfdeconv produce the same remainder as the example in the Williams example? I understand that I'm probably suppose to flip and/or transpose the poly and/or the original message, but I am unsure of the method.

Thank you.


Solution

  • You need to provide the coefficients in the other order, i.e. the coefficient of 1 (x0) first. You then need to provide the appended zeros first, so the correct usage is:

    [q, r] = gfdeconv([0 0 0 0 1 1 0 1 1 0 1 0 1 1], [1 1 0 0 1])
    

    The result is:

    q =
    
         0     1     0     1     0     0     0     0     1     1
    
    
    r =
    
         0     1     1     1
    

    where r is the expected result, also with the least significant bit first.