Check digit

From Wikipedia, the free encyclopedia

A check digit is a form of redundancy check used for error detection, the decimal equivalent of a binary checksum. It consists of a single digit computed from the other digits in the message.

Contents

[edit] Examples

[edit] UPC

The final digit of a Universal Product Code is a check digit computed as follows:

  1. Add the digits in the odd-numbered positions (first, third, fifth, etc.) together and multiply by three.
  2. Add the digits in the even-numbered positions (second, fourth, sixth, etc.) to the result.
  3. Subtract the result from the next-higher multiple of ten. The answer is the check digit.

For instance, a UPC-A barcode (In this case, a UPC for a box of tissues) "03600029145X" where X is the check digit, X can be calculated by adding the odd-numbered digits (0+6+0+2+1+5 = 14), multiplying by three (14 × 3 = 42), adding the even-numbered digits (42+3+0+0+9+4 = 58) and subtracting from the next-higher multiple of ten (60 - 58 = 2). The check digit is thus 2.

[edit] ISBN 10

The final character of a ten digit International Standard Book Number is a check digit computed so that multiplying each digit by its position in the number (counting from the right) and taking the sum of these products modulo 11, is 0. The last digit (which is multiplied by 1) is the check digit, chosen to make the sum correct. It may need to have the value 10, which is represented as the letter X. For example, take the ISBN 0-201-53082-1. The sum of products is 0×10 + 2×9 + 0×8 + 1×7 + 5×6 + 3×5 + 0×4 + 8×3 + 2×2 + 1×1 = 99 modulo 11 ≡ 0. So the ISBN is valid.

While this may seem more complicated than the first scheme, it can actually compute very simply using two sums, both initialized to 0:

sum1 = sum2 = 0
for (each digit of the ISBN)
    sum1 = sum1 + digit
    sum2 = sum2 + sum1

the final sum2 should be a multiple of 11.

ISBN 13 (in use January, 2007) generates its check digit the same way as the UPC.

[edit] Other examples of check digits

Compare to check bit.

[edit] External links