Simplify old multiply logic for GF

git-svn-id: https://zxing.googlecode.com/svn/trunk@2185 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-02-15 08:35:25 +00:00
parent 0cf9ec342f
commit f1dc6c6dcd

View file

@ -163,26 +163,18 @@ public final class GenericGF {
} }
/** /**
* @param a
* @param b
* @return product of a and b in GF(size) * @return product of a and b in GF(size)
*/ */
int multiply(int a, int b) { int multiply(int a, int b) {
checkInit(); checkInit();
if (a == 0 || b == 0) { if (a == 0 || b == 0) {
return 0; return 0;
} }
return expTable[(logTable[a] + logTable[b]) % (size - 1)];
if (a<0 || b <0 || a>=size || b >=size){
a++;
}
int logSum = logTable[a] + logTable[b];
return expTable[(logSum % size) + logSum / size];
} }
public int getSize(){ public int getSize() {
return size; return size;
} }