4

I'd like to confirm whether I grasped the concept of CRC calculations correctly. I'll provide two examples, the first is calculating the remainder using normal subtraction, the second uses this weird XOR stuff.

Data bits: D = 1010101010.
Generator bits: G = 10001.

1) Subtraction approach to calculate remainder:

10101010100000
10001|||||||||
-----|||||||||
  10001|||||||
  10001|||||||
  -----|||||||
  000000100000
         10001
         -----
          1111

R = 1111.

2) XOR approach:

10101010100000
10001|||||||||
-----|||||||||
  10001|||||||
  10001|||||||
  -----|||||||
  00000010000|
        10001|
        ------
        000010

R = 0010.

Nayuki
  • 17,911
  • 6
  • 53
  • 80
NameZero912
  • 43
  • 1
  • 1
  • 4
  • I should probably attach the question, all right: CRC uses the XOR approach, right? Did I do the XOR-example correctly? – NameZero912 Feb 14 '11 at 17:44

3 Answers3

2

Appending 1111 at the end does not satisfy the need since

10927 % 17 != 0

.

Note that as per the definition, the division should be modulo division as it is based upon modulo mathematics.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ramakanth
  • 21
  • 2
1

Both answers are correct. =)

(To recheck the first answer:
10101010100000 (binary) mod 10001 (binary)
= 10912 (decimal) mod 17 (decimal)
= 15 (decimal)
= 1111 (binary).)

Nayuki
  • 17,911
  • 6
  • 53
  • 80
-2

Subtraction is wrongly done. In binary modulo, subtraction, addition, division, and multiplication are the same. So, XOR is correct.

kosuke
  • 11
  • Multiplication is not the same (1*1 = 1, everything else is 0), and division seems trivial at best. – Ivo Apr 20 '17 at 22:36