diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index db4d83e..47b7195 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -608,16 +608,16 @@ public final class QrCode { // Finder-like pattern in rows for (int y = 0; y < size; y++) { for (int x = 0, bits = 0; x < size; x++) { - bits = ((bits << 1) & 0x7FF) | (modules[y][x] ? 1 : 0); - if (x >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated + bits = ((bits << 1) & 0b11111111111) | (modules[y][x] ? 1 : 0); + if (x >= 10 && (bits == 0b00001011101 || bits == 0b10111010000)) // Needs 11 bits accumulated result += PENALTY_N3; } } // Finder-like pattern in columns for (int x = 0; x < size; x++) { for (int y = 0, bits = 0; y < size; y++) { - bits = ((bits << 1) & 0x7FF) | (modules[y][x] ? 1 : 0); - if (y >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated + bits = ((bits << 1) & 0b11111111111) | (modules[y][x] ? 1 : 0); + if (y >= 10 && (bits == 0b00001011101 || bits == 0b10111010000)) // Needs 11 bits accumulated result += PENALTY_N3; } } diff --git a/typescript/qrcodegen.ts b/typescript/qrcodegen.ts index fa4f9eb..420407d 100644 --- a/typescript/qrcodegen.ts +++ b/typescript/qrcodegen.ts @@ -527,16 +527,16 @@ namespace qrcodegen { // Finder-like pattern in rows for (let y = 0; y < this.size; y++) { for (let x = 0, bits = 0; x < this.size; x++) { - bits = ((bits << 1) & 0x7FF) | (this.modules[y][x] ? 1 : 0); - if (x >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated + bits = ((bits << 1) & 0b11111111111) | (this.modules[y][x] ? 1 : 0); + if (x >= 10 && (bits == 0b00001011101 || bits == 0b10111010000)) // Needs 11 bits accumulated result += QrCode.PENALTY_N3; } } // Finder-like pattern in columns for (let x = 0; x < this.size; x++) { for (let y = 0, bits = 0; y < this.size; y++) { - bits = ((bits << 1) & 0x7FF) | (this.modules[y][x] ? 1 : 0); - if (y >= 10 && (bits == 0x05D || bits == 0x5D0)) // Needs 11 bits accumulated + bits = ((bits << 1) & 0b11111111111) | (this.modules[y][x] ? 1 : 0); + if (y >= 10 && (bits == 0b00001011101 || bits == 0b10111010000)) // Needs 11 bits accumulated result += QrCode.PENALTY_N3; } }