Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

modulus 11 performance

807607Nov 27 2006 — edited Nov 27 2006
Hi

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);
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 25 2006
Added on Nov 27 2006
2 comments
168 views