1. Galois Field GF(256) Arithmetic
Reed-Solomon in QR codes operates over GF(2^8) — a finite field of 256 elements. Each element is an 8-bit byte (0–255). The field is constructed from the irreducible primitive polynomial:
```
p(x) = x^8 + x^4 + x^3 + x^2 + 1 (decimal 285)
```
In GF(256):
- Addition is XOR (bitwise).
- Multiplication uses logarithm tables (pre-computed exponents of the primitive element α = 2).
- Division is multiplication by the multiplicative inverse.
There are no carries in GF(256) arithmetic — subtraction is identical to addition (XOR).
2. Generator Polynomial
For a block with 2t parity codewords, the generator polynomial is:
```
g(x) = (x - α^0)(x - α^1)(x - α^2) ... (x - α^(2t-1))
```
For 10 parity bytes (t=5, can correct 5 errors):
```
g(x) = (x + α^0)(x + α^1)(x + α^2)(x + α^3)(x + α^4)(x + α^5)(x + α^6)(x + α^7)(x + α^8)(x + α^9)
```
(In GF(2^8), subtraction equals addition, so x - α^i = x + α^i.)
3. Parity Computation
Represent the data codewords as polynomial D(x). Multiply by x^(2t) to shift them, then divide by g(x). The remainder R(x) contains the 2t parity codewords appended to D(x).
```python
def gf_poly_div(dividend, divisor):
result = list(dividend)
for i in range(len(dividend) - len(divisor) + 1):
coef = result[i]
if coef != 0:
for j in range(1, len(divisor)):
if divisor[j] != 0:
result[i + j] ^= gf_mul(divisor[j], coef)
return result[-(len(divisor)-1):] # remainder only
```
4. Interleaving for Burst Error Resilience
Large QR symbols split data into multiple blocks and interleave the codewords. If a burst of damage (e.g., a tear) corrupts consecutive codewords, interleaving ensures that the consecutive physical codewords belong to different logical blocks — distributing the damage so no single block exceeds its correction capacity.
5. Error vs Erasure Correction
Standard decoding corrects errors (unknown location, unknown value): up to t errors per block. If the location of damage is known (erasure — e.g., the QR was printed with a logo covering a defined region), erasure decoding corrects up to 2t erasures per block. Knowing the location of damage doubles correction capacity.
Putting this into practice
Start with the smallest real test you can run. Generate the code, print it at the exact size you plan to use, and scan it with two different phones in the lighting where it will live. Check that the destination page loads quickly on a mobile connection and that the call to action next to the code tells people what they will get. If anything feels slow or unclear, fix it before you print a full batch, because reprints cost more than a short test. Keep a note of the size, material, and placement that worked so the next batch starts from a proven setup.
Common mistakes to avoid
The most common mistakes are easy to avoid once you know them. Long payloads make modules tiny, low contrast makes edges hard to read, and text placed too close to the border eats the quiet zone the scanner needs. Covering a corner finder pattern with a logo or a sticker breaks detection entirely, and a code placed behind glare or on a curved surface fails even when the print is perfect. Review each of these points on a proof copy, and treat any failure as a reason to adjust the design rather than a reason to blame the scanner.
Quick checklist
- Keep the payload as short as practical so modules stay large.
- Keep dark modules on a light background with strong contrast.
- Leave a clear quiet zone on all four sides of the symbol.
- Test the printed code at the real viewing distance and lighting.
- Confirm the destination page loads fast on a phone.
- Recheck the code after any change to the link, design, or placement.
Related tools and guides
- Use the [QR size calculator](/qr-size-calculator) to match the printed size to the expected scan distance before you commit to a print run.
- The [error correction simulator](/error-correction-simulator) shows how damage tolerance changes the density of the symbol at each level.
- Test every code with the [QR scanner](/qr-scanner) on more than one phone before you publish or print it.
- Create a fresh code with the [URL QR code generator](/url-qr-code-generator) when the destination is a web page.
- Run unfamiliar destinations through the [QR safety checker](/qr-safety-checker) before you share a code widely.
- The [blog](/blog) collects more guides on sizing, printing, security, and payments for QR codes.