modulus 11 performance
807607Nov 27 2006 — edited Nov 27 2006Hi
Im trying to improve performance on a modulus 11 method. Its not in Java, but im more used to Java so I think in Java, and I ask here because i normally get super response on the forum. I hope its ok.
I have this "slow" code here under, and i belive its slow because it uses string operations. However i dont have a idea how to change it so it does not use string operations. Any ideas guys? A reply in Java code will be perfect :)
static int modulo11(str 20 numeralsTxt)
{
int numerals;
int vector;
int sumNumerals;
vector = 2;
sumNumerals = 0;
numeralsTxt = strKeep(numeralsTxt,'0123456789');
sumNumerals = str2num(subStr(numeralsTxt,999,-2));
numeralsTxt = strDel(numeralsTxt,999,-2);
while (numeralsTxt)
{
numerals = str2num(subStr(numeralsTxt,999,-2)) * vector;
numeralsTxt = strDel(numeralsTxt,999,-2);
sumNumerals += numerals;
vector += 1;
if (vector > 7)
{
vector = 2;
}
}
return ((sumNumerals mod 11) == 0);
}