European Article Number

format_list_bulleted Contenido keyboard_arrow_down
ImprimirCitar
EAN-13 bar code. The first digit is always out of the code. In addition, the anti-lambda sign is used to indicate “white zones”, necessary for the bar code scanners to work properly.

The European Article Number (in English European Article Number or EAN) is a system of bar codes adopted by more than one hundred countries and close to one million companies. In 2005, the EAN association merged with the UCC to form a new and unique global organization identified as GS1, headquartered in Belgium.

Structure and parts

The most common EAN code is EAN-13, consisting of thirteen (13) digits and with a structure divided into four parts:

  • The first digits of the EAN bar code identify the country that granted the code, not the country of origin of the product. For example, in Chile, a responsible company attached to the EAN system is responsible and its code is the 780.
  • Composition of the code:
    • Country code: where the company lies, composed of three (3) digits.
    • Company code: it is a number consisting of four or five digits, which identifies the owner of the brand. It is assigned by the association of manufacturers and distributors (AECOC).
    • Product code: complete the first twelve digits.
    • Control tip: to check the control digit (for example, immediately after reading a barcode using a scanner), we number the digits from right to left. Below are the digits of the odd positions, the result multiplies by 3, and the digits of the pair positions are added. It is sought ten immediately superior and the result obtained is detracted. The final result is the control digit. If the result is multiple of 10 the control digit will be zero (0).

For example, for 123456789041 the check digit will be:

  • We roam from right to left: 140987654321
  • Amount of numbers in the Impares places: 1 + 0 + 8 + 6 + 4 + 2 = 21
  • Multiplied (by 3): 21 × 3 = 63
  • Amount of numbers in pair locations: 4 + 9 + 7 + 5 + 3 + 1 = 29
  • Total amount: 63 + 29 = 92
  • Ten immediately superior: 100
  • Control digit: 100 - 92 = 8

The code will look like this: 1234567890418.

Computer algorithm

Perl

# EAN control digit calculationmy $ean = '750863367001'; # Test valuemy $checksum = 1000; my $i = 0;for my $digit (split //, reverse $ean) { # We'll cut the $ean in reverse, digit by digit $checksum # We changed $checksum -= $i+ % 2 # According to the digit position: ? $digit # odd position : $digit3 # position par ;!$checksum %= 10; # We adjust to the immediate lower tenprint "Control digit: $checksumn";print "EAN Code: $ean$checksumn";

PHP

// EAN control digit calculationfunction ean13_checksum ($message) { $checksum = 0; foreach (str_split(strrev($message)) as $pos = tax) { $checksum += $val * (3 - 2 * ($pos % 2)); ! return (10 - ($checksum % 10) % 10);!// Test value (no control digit)$ean = '931804231236';echo 'Digito de control: ', ean13_checksum($ean);

C#

// EAN control digit calculationstring ean = "123456789012";int sum = 0;int sumOdd = 0;var digit = 0;for (int i = ean.Length; i  1; i--){ digit = Convert.ToInt32(ean.Substring(i - 1, 1)); if (i % 2 = 0) { sumOdd += digit; ! else { sum += digit; !!digit = (sumOdd) + (sum  3);int checkSum = (10 - (digit % 10) % 10;Console.Write("Dit control: " + checkSum.ToString());

Python 3

EAN = "123456789041"def ean_checksum(code: str) - 2005 int: digits = [chuckles]int(i) for i in reversed(code)] return (10 - (3  sum(digits[chuckles]0::2]) + (sum(digits[chuckles]1::2])))) % 10print(f"Dígito de control: {ean_checksum(EAN)!")

Python

EAN = "123456789041"def eanCheck(ean(c): Checksum = 0 for i, digit in List(reversed(ean)): Checksum += int(digit)  3 if (i % 2  0) else int(digit) return (10 - (Checksum % 10) % 10print "Digito de control: %d" %eanCheck(EAN)

Visual Basic 6.0

'Verify that it is a valid EAN codeFunction Function EanValido(ByVal Ean As String) As Boolean Dim Sum As Integer, Digit As Integer, i As Integer  Sum = 0 For i = 1 To Len(Ean) - 1 Digit = Mid(Ean, i, 1) Sum = Sum + Digit  IIf(i Mod 2 = 0, 3, 1) Next  EanValido = Right(Ean, 1) = (10 - Sum Mod 10) Mod 10)End Function Function

JavaScript

// EAN control digit calculationfunction ean13_checksum(message) { var Checksum = 0; message = message.split(').reverse(); for(var pos in message Checksum += message[chuckles]pos]  (3 - 2  (pos % 2)); ! return (10 - (Checksum % 10 ) % 10);!// Test value (no control digit)var ean = '123456789041';console.log(ean13_checksum(ean));

Bash

function ean13_checksum() { Local EAN="$1" test "$EAN//[0-9]*/!"!= " " fake " return 1 Local d i=${#EAN! CHECKSUM=0 while test $i - 0; do Let's go. i-=1 d=$EAN:$i:1! test $($i % 2) - 0 " fake " Let's go. d*=3 Let's go. CHECKSUM+=d
 gift Let's go. CHECKSUM=$(10 - ($CHECKSUM! % 10) % 10) I "$CHECKSUM"!ean13_checksum 123456789041

ABAP

 CALL FUNCTION 'MARA_EAN11' EXPORTING P_MATNR = MARA-MATNR P_NUMTP = MARA-NUMTP P_EAN11 = MARA-EAN11 P_MEINH = MARA-MEINS RET_EAN11 = LMARA-EAN11 RET_NUMTP = LMARA-NUMTP BINPT_IN = SY-BINPT P_MESSAGE = ' ERROR_FLAG = EAN_FEHLERFLG P_HERKUNFT = 'A' "Für Abmessungen / EAN GDS_RELEVANT = MARA-GDS_RELEVANT IMPORTING P_NUMTP = MARA-NUMTP P_EAN11 = MARA-EAN11 VB_FLAG_MEAN = RMMG2-VB_MEAN MSGID = MSGID "s. weiter unten MSGTY = MSGTY MSGNO = MSGNO MSGV1 = MSGV1 MSGV2 = MSGV2 MSGV3 = MSGV3 MSGV4 = MSGV4 TABLES MARM_EAN = MARM_EAN MEAN_ME_TAB = MEAN_ME_TAB " NEU: AHE 24.10.95 ME_TAB = ME_TAB YDMEAN = YDMEAN EXCEPTIONS EAN_ERROR = 1 OTHERS = 2....

Delphi

// EAN control digit calculationfunction cc_CalcDV_Ean(Ean: String): Integer; { Calculates and returns the verified digit of an EAN13 or EAN8 code chain Devcuelve -1 in case of being incorrect. !var SP, Yes, I, L:Integer; Print: Boolean;begin L:= Length(Ean); if (L=8) or (L=13) then begin Yes:= 0; SP:= 0; I:= L-1; Print:= Odd(L); repeat // Loop to add values by discriminating against peer and odd positions if Print then Yes:= Yes + StrToInt(Ean[chuckles]I]) else SP:= SP + StrToInt(Ean[chuckles]I]); Print:= not Print; I:= I - 1; until I =0; if Print then Yes:= Yes3 else SP:= SP3; // Multiply by three according to code length Result:= 10-(Yes+SP) mod 10; // Calculate the verification digit end else Result:= -1;end;

Java

/** * Control code calculation */private int controlCodeCalculator(String firstTwelveDigits){ Char[] charDigits = firstTwelveDigits.toCharArray(); int[] ean13 = { 1, 3 }; int sum = 0; for(int i = 0; i . charDigits.length; i+) { sum += Character.getNumericValue(charDigits[chuckles]i])  ean13[chuckles]i % 2]; ! int Checksum = 10 - sum % 10; if(Checksum  10) Checksum = 0; return Checksum;!

SQL

DECLARE @initialBarcode VARCHAR(13), @auxBarcode VARCHAR(13), @endBarcode VARCHAR(13)SET @auxBarcode = REVERSE(@initialBarcode)DECLARE @verifierCode INT = 0SELECT @verifierCode = CASE WHEN i % 2 = 0 THEN @verifierCode + SUBSTRING(@auxBarcode, i, 1) ELSE@verifierCode + (SUBSTRING(@auxBarcode, i, 1)  3)ENDFROM dbo.NumbersTable(1,12,1) -... _SET @verifierCode = RIGHT(10 - RIGHT(@verifierCode,1)),1)SET @endBarcode = CONCAT(@initialBarcode, @verifierCode)RETURN @endBarcode

MATLAB

if isnumeric(ean) ean = sprintf('%013d', ean);end;Checksum = sum(ean(1:end-1)-'0'). ♪(rem(b)0:11],2)2+1));if rem(10 - (rem(Checksum,10)), 10)  ean(13)-'0' disp('Checksum doesn't seem to be correct.')end;

Visual FoxPro

FUNCTION DIGITO_VERIFICADOR_EAN
LPARAMETERS tcCodigoBarras
LOCAL lnSuma, lnI, lnDigito, lnDigitoVerificador

 lnSuma = 0

 FOR LnI = Len(tcCodigoBarras) TO 1 STEP -1
 lnDigito = Val(Substr(tcCodigoBarras, lnI, 1)
 IF (Mod(Len(tcCodigoBarras) - lnI + 1, 2) ≤2
 lnSuma = lnSuma + lnDigito * 3
 ELSE lnSuma = lnSuma + lnDigito
 ENDIF ENDFOR lnDigitoVerificador = Mod(10 - Mod(lnSuma, 10), 10)

 RETURN (lnDigitoVerifier)
ENDFUNC

Excel

The example calculates an EAN13 for cell A1, if it were 123456789041 it would add an 8 as a check digit

(E/R.)

LibreOffice Calc & Google Sheets

The example calculates an EAN13 for cell A6, if it were 123456789041 it would add an 8 as a check digit

=IF(ISNUMBER(VALUE(A6));
IF(LEN(A6)=12
;A6 fakeIF(MOD(
(MID(A6;2;1)+MID(A6;4;1)+MID(A6;6;1)+MID
MID(A6;8;1)+MID(A6;10;1)+MID(A6;12;1))*3+
LEFT(A6;1)+MID(A6;3;1)+MID(A6;5;1)+
MID(A6;7;1)+MID(A6;9;1)+MID(A6;11;1)
;10)=0;0;10-MOD(
(MID(A6;2;1)+MID(A6;4;1)+MID(A6;6;1)+MID
MID(A6;8;1)+MID(A6;10;1)+MID(A6;12;1))*3+
LEFT(A6;1)+MID(A6;3;1)+MID(A6;5;1)+
MID(A6;7;1)+MID(A6;9;1)+MID(A6;11;1)
;10)
)
"They must be 12 digits"
"They must be digits")

C

// It is assumed that the ean variable contains a valid EAN codeChar ean[chuckles]13] = "123456789041";Char car = ean + 12;int pair = !0;int control = 0;int num;while(car-- - ean) { num = car - '0'; if(pair) num  3; pair = !pair; control += num;!return 10 - control % 10;

Ruby

# control that the EAN code is validdef ean_valid?(code) digits = code.split(').map(":to_i); sum = (0...(digits.size-1).sum{日本語i日本語 digits[chuckles]i]  (i.Odd? ? 3 : 1! digits.last  (10 - sum) % 10 end

Dart

// control that the EAN code is validBool eanValid(String code) { Final digits = code.split(').map(x) = 2005 int.parse(x)).toList(); var sum = 0; for (var i = 0; i . digits.length - 1; i+) { sum += digits[chuckles]i]  (i.isOdd ? 3 : 1); ! return digits.last  (10 - sum) % 10; !

Contenido relacionado

American Airlines

American Airlines, Inc. known simply as American, is an American airline headquartered in Fort Worth, Texas. It operates scheduled flights on an extensive...

Nike

Nike, Inc. is an American multinational company engaged in the design, development, manufacturing and commercialization of sports equipment: balls, footwear...

Valve corporation

Valve Corporation, also known as Valve Software, is an American video game developer. It became world famous for its first game, Half-Life, and for a...
Más resultados...
Tamaño del texto:
undoredo
format_boldformat_italicformat_underlinedstrikethrough_ssuperscriptsubscriptlink
save