Simplified another pair of bit width checks using the right shift operator.
This commit is contained in:
parent
53454449c4
commit
7f01bbf4f3
|
@ -375,7 +375,7 @@ public final class QrCode {
|
|||
rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
|
||||
data = data << 10 | rem;
|
||||
data ^= 0x5412; // uint15
|
||||
if ((data & ((1 << 15) - 1)) != data)
|
||||
if (data >>> 15 != 0)
|
||||
throw new AssertionError();
|
||||
|
||||
// Draw first copy
|
||||
|
@ -407,7 +407,7 @@ public final class QrCode {
|
|||
for (int i = 0; i < 12; i++)
|
||||
rem = (rem << 1) ^ ((rem >>> 11) * 0x1F25);
|
||||
int data = version << 12 | rem; // uint18
|
||||
if ((data & ((1 << 18) - 1)) != data)
|
||||
if (data >>> 18 != 0)
|
||||
throw new AssertionError();
|
||||
|
||||
// Draw two copies
|
||||
|
|
|
@ -354,7 +354,7 @@ var qrcodegen = new function() {
|
|||
rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
|
||||
data = data << 10 | rem;
|
||||
data ^= 0x5412; // uint15
|
||||
if ((data & ((1 << 15) - 1)) != data)
|
||||
if (data >>> 15 != 0)
|
||||
throw "Assertion error";
|
||||
|
||||
// Draw first copy
|
||||
|
@ -386,7 +386,7 @@ var qrcodegen = new function() {
|
|||
for (var i = 0; i < 12; i++)
|
||||
rem = (rem << 1) ^ ((rem >>> 11) * 0x1F25);
|
||||
var data = version << 12 | rem; // uint18
|
||||
if ((data & ((1 << 18) - 1)) != data)
|
||||
if (data >>> 18 != 0)
|
||||
throw "Assertion error";
|
||||
|
||||
// Draw two copies
|
||||
|
|
|
@ -294,7 +294,7 @@ class QrCode(object):
|
|||
rem = (rem << 1) ^ ((rem >> 9) * 0x537)
|
||||
data = data << 10 | rem
|
||||
data ^= 0x5412 # uint15
|
||||
assert data & ((1 << 15) - 1) == data
|
||||
assert data >> 15 == 0
|
||||
|
||||
# Draw first copy
|
||||
for i in range(0, 6):
|
||||
|
@ -324,7 +324,7 @@ class QrCode(object):
|
|||
for _ in range(12):
|
||||
rem = (rem << 1) ^ ((rem >> 11) * 0x1F25)
|
||||
data = self._version << 12 | rem # uint18
|
||||
assert data & ((1 << 18) - 1) == data
|
||||
assert data >> 18 == 0
|
||||
|
||||
# Draw two copies
|
||||
for i in range(18):
|
||||
|
|
Loading…
Reference in New Issue