Tag Archives: Check digit

Motor vehicles have a 17-character Vehicle Identification Number or VIN on a metal plate like the one below, usually on the driver’s side dashboard, or on the driver’s side door jamb, or in front of the engine block:

A Vehicle Identification Number (VIN) plate (Photo: Michiel1972)

VINs offer an interesting example of check digit calculation. The central digit (or an X representing 10) is a check digit (calculated modulo 11) used to detect errors. Any letters in the rest of the VIN are decoded like this:

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

1

2

3

4

5

6

7

8

–

1

2

3

4

5

–

7

–

9

2

3

4

5

6

7

8

9

The check digit calculation involves decoding the VIN, and multiplying the resulting numbers by the weights shown in blue, giving the products in purple:

VIN

L

J

C

P

C

B

L

C

X

1

1

0

0

0

2

3

7

Decoded

3

1

3

7

3

2

3

3

10

1

1

0

0

0

2

3

7

Weights

8

7

6

5

4

3

2

10

0

9

8

7

6

5

4

3

2

Product

24

7

18

35

12

6

6

30

0

9

8

0

0

0

8

9

14

These products are added up modulo 11 (meaning the sum is divided by 11 and the remainder taken). In this case, the sum is 186 = 10 = X (mod 11), which makes the VIN valid, because it matches the original central X. What about the VIN on your vehicle?

International Standard Book Numbers or ISBNs (the older, 10-digit kind, not the newer 13-digit kind starting with 978) have an interesting way of detecting errors made in writing down the numbers. The number at the top of the image above is an example of what I mean. The process works like this:

Circle the right-hand digit. This is the check digit. If it’s an “X,” that means 10. In the image above, the check digit (5) is circled in red.

The check digit should be 0 if R = 0, and 11 − R otherwise. If not, something is wrong. For the example above, the check digit is 11 − 6 = 5 (for students familiar with modular arithmetic, we can express this more simply: the check digit should be −Smod 11).

This scheme will detect any copying error where a single digit gets changed. Imagine that one of the digits is A (ranging from 0 to 9), in the position where it gets multiplied by N (ranging from 10 to 2), and A gets replaced by a different digit B (ranging from 0 to 9). The sum S will increase by (B − A)N, which cannot be a multiple of 11. Therefore the remainder R will change, and the check digit calculated in step 5 will no longer match the circled one.

The ISBN system also spots digits being swapped. Imagine that one of the digits is A (ranging from 0 to 9), in the position where it gets multiplied by N (ranging from 10 to 2). Another digit is B (ranging from 0 to 9, with B ≠ A), in the position where it gets multiplied by M (ranging from 10 to 2, with M ≠ N). If the digits A and B are swapped, by a similar argument to the one above, the check digit calculated in step 5 will no longer match the circled one.

A number of similar schemes exist, since the problem of people writing down numbers incorrectly is widespread, and detecting such errors is often worthwhile. Australian Medicare cards, like the one above, operate as follows:

Ignore the right-hand digit, which is a sequence number. Circle the digit second from the right. This is the check digit. In the image above, the check digit (8) is circled in red.

The check digit should R. For the example above, the check digit is 8.

This scheme will also detect any copying error where a single digit gets changed. Imagine that one of the digits is A (ranging from 0 to 9), in the position where it gets multiplied by N (1, 3, 7, or 9), and A gets replaced by a different digit B (ranging from 0 to 9). The sum S will increase by (B − A)N, which cannot be a multiple of 10 (this is why 5 is excluded as one of the multiplying numbers). Therefore the remainder R will change, and the check digit calculated in step 5 will no longer match the circled one.

However, the Australian Medicare Number scheme only detects some digit swaps. Even if we only worry about swapping adjacent digits, it does not catch all such errors. For example, 127456786 and 172456786 are both valid. If you imagine that one of the digits is A (in the position where it gets multiplied by N) and the adjacent digit is B (in the position where it gets multiplied by M), you can see that sometimes the change in S from a swap will be a multiple of 10, leaving the check digit unchanged.