# Check digit

A check digit is the simplest form of a checksum . The check digit of a multi-digit number is calculated from the remaining digits according to a certain calculation rule . Input errors can be detected by calculating and comparing the check digit.

If the check digit can have ten values, a random match occurs even with invalid numbers with a 10% probability. If two check digits are used, this error probability is only 1%.

Check digits can be used both with manual input via the keyboard and with automatic data acquisition , e.g. B. OCR or barcode readers can be used. In a data acquisition device , the entry can be rejected if the check digit is different.

## Example: Deutsche Post identity code

The check digit calculation is carried out when the identity code of the Deutsche Post in modulo -11-method

```Code        : 4  7  3  1  2  4  8  2
Gewichtung  : 8  6  4  2  3  5  9  7
Produkte    : 32 42 12 2  6  20 72 14
Summe       : 200
Modulo 11   : 200 / 11 = 18 Rest 2
Prüfziffer  : Differenz zu 11 = 11 - 2 = 9
Ausnahmen   :
Wenn Differenz zu 11 = 10: Prüfziffer wird zu 0
Wenn Differenz zu 11 = 11: Prüfziffer wird zu 5
```
Identcode of the Deutsche Post / DHL

Calculation of the check digit:

• From left to right, the digits are weighted with 8, 6, 4, 2, 3, 5, 9 and 7. In contrast to a simple summation of the code digits, interchanges of two digits can also be recognized.
• The individual code and weighting digits are multiplied and the products are then added.
• The sum is calculated modulo 11, i.e. only the remainder of the division by 11 (i.e. only one digit) is taken into account. Residual formation can also take place immediately after product formation.
• The check digit is the difference between the remainder and 11 (see above for exceptions).

Calculation of the identity code in a formula using Excel as an example :

• The eight-digit code is in cell A1
• formula
``` =A1&TEIL("012345678905";12-REST(TEIL(A1;1;1)*8+TEIL(A1;2;1)*6+TEIL(A1;3;1)*4+TEIL(A1;4;1)*2+TEIL(A1;5;1)*3+TEIL(A1;6;1)*5+TEIL(A1;7;1)*9+TEIL(A1;8;1)*7;11);1)
```