Skip to content

Instantly share code, notes, and snippets.

@CalvinRodo
Created June 7, 2012 12:24
Show Gist options
  • Save CalvinRodo/2888539 to your computer and use it in GitHub Desktop.
Save CalvinRodo/2888539 to your computer and use it in GitHub Desktop.
for (int j = 0; j < 8; j++)
{
long firstCalc = CRCTable[counterOne] << 1;
long secondCalc = CRCTable[counterOne] & (1 << 31); //or CRCTable[counterOne] & (5)
CRCTable[counterOne] = firstCalc ^ ((secondCalc == 0)? polynom : 0);
}
//Or this would also be equivelant
for (int j = 0; j < 8; j++)
{
CRCTable[counterOne] = (CRCTable[counterOne] << 1) ^ (((CRCTable[counterOne] & (1 << 31)) == 0)? polynom : 0);
}
//or this
for (int j = 0; j < 8; j++)
{
long firstCalc = CRCTable[counterOne] << 1;
long secondCalc;
if ((CRCTable[counterOne] & (1 << 31)) == 0)
secondCalc = polynom;
else
secondCalc = 0
CRCTable[counterOne] = firstCalc ^ secondCalc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment