| Tip: Bookmark this page with Ctrl-D (Win) or Apple-D (Mac) | Main • Products • Know How / FAQ • Store • Contact |
Barcode Symbologies
How do I calculate a Code EAN 13 checksum or check digit?Code EAN uses a simple Modulo 10 checksum scheme. The 12 (or 7 in case of EAN 8) digits of the message are multiplied with '1' and '3' (alternating). The products are then summed up and integer divided by ten. The remainder (modulo) of the division is subtracted from '10', the result is the check digit.
Here is a simplified EAN 13 checksum function in C:
int _checksum_ean13(char *data)
{
int sum = 0;
int i;
for(i=11;i>=0;i--)
{
int digit = *(data + i);
if(i & 0x01)
sum += digit * 3;
else
sum += digit;
}
int mod = sum % 10;
if(mod != 0)
return 10 - mod;
return 0;
}
Note: All our applications and developer components and libraries have automatic checksum calculation for Code EAN 8 / 13 and ISBN 10 / 13.
Make sure to also see our introductory article about Code EAN and Code ISBN.
EAN Barcode Software
- Barcode AddIn for Microsoft Word
- Barcode AddIn for Microsoft Excel
- Barcode Plugin for Illustrator
- Barcode Plugin for Indesign
- Barcode Command Line Tool
- .NET Barcode Library & Control
- C / C++ Barcode DLL


