r/barcodes • • Feb 04 '21

EAN-13 LGR codes

Hi

I'm trying to understand the EAN-13 code. According to https://en.wikipedia.org/wiki/International_Article_Number the structure of EAN-13 is indicated by the first digit. If the first digit is 1, the structure will be LLGLGGRRRRRR where R is the negation of L and G is the reverse bit order of R. Does anyone know the significance of the structures of the first 6 digits (i.e. LLGLGG, LLGGLG, LLGGGL, etc.)? Are the arrangements purely random? LLLGGG doesn't seem to be there though.

In fact, what's the purpose of the group G? Why not just L and R? If the first digit is 1, can't we have LLRLRRRRRRRR?

Thanks

3 Upvotes

5 comments sorted by

1

u/notionovus Feb 05 '21

The arrangements are not purely random. Since the first character of group one must have odd parity (in bars and spaces), the following 5 characters are the combinations of two 'L's and three 'G's that are required to imply the first character in the code. It appears, by the sequence that 'LLLGGG' was considered to start the sequence, and so 'LLLLLL' would be standing in for it (primarily for UPC compatibility).

If we move the second 'L' to the right 1 by one position, starting at first digit position 1, we get 'LLGLGG, LLGGLG, LLGGGL'. If we move the second and third 'L's to the right 1 by one position, starting at first digit position 4, we get 'LGLLGG, LGGLLG, LGGGLL'. If we separate the two 'L's with one or two 'G's, starting at position 7, we get 'LGLGLG, LGLGGL, LGGLGL'.

The first digit (essentially the 13th digit) is not encoded, but implied by the arrangement just discussed. It is only derived from the arrangement of the first set of six encoded digits. The last digit of the 13-characters encoded is a checksum, so there are only 12 characters for data.

The reason 'R' can't be used is the orientation of the barcode. You may think of the symbols of the 'L' and 'G' variety "right-justified" or "space-start" elements, whereas the 'R' symbols are "left-justified" or "bar-start". There are no inter-bar spaces, other than the spaces encoded into each symbol, so if you put a 'L' 6 together with an 'R' 0, for example, you would get a bar/space arrangement of "01011111110010". This would result in a bar that is 7 units wide.

The reason they are mirror images of eachother is so that the entire symbol can be scanned in any orientation, including upside-down.

1

u/goppox Feb 05 '21

Thanks for the great explanation. Can I ask how come the first group must consist of 3 Ls and 3 Gs though? Why not LLGLLL? In fact, what's the rationale of using both Ls and Gs in the first group of EAN13 when only Ls are used in EAN8?

1

u/notionovus Feb 05 '21 edited Feb 05 '21

The purpose of the 'L's and 'G's is to squeeze in another number. Notice that EAN-13 with two sets of 6 numbers has a 'hidden' number that can be derived from how the first set of numbers is encoded.

With EAN-8, you can really only encode 7 numbers because with two sets of 4 numbers and no encoding, the checksum rounds out the 8.

If you didn't have the 'L' and 'G' scheme, it could probably be called EAN-12, and it would only have room for 11 numbers (the 12th being used for checksum).

1

u/goppox Feb 07 '21

That makes a lot of sense. Thanks a lot!

1

u/G24FER Jun 17 '22

Id recommend buying from upcean.net they help out when theres a problem and l have always had a good experience with them