What is the sentence mean?Thanks

Y

yezi

Hi, All:

I am reading the following code:

unsigned long crcbitbybitfast(unsigned char* p, unsigned long len) {

// fast bit by bit algorithm without augmented zero bytes.
// does not use lookup table, suited for polynom orders between
1...32.

unsigned long i, j, c, bit;
unsigned long crc = crcinit_direct;

for (i=0; i<len; i++) {

c = (unsigned long)*p++;

for (j=0x80; j; j>>=1) {

bit = crc & crchighbit;
crc<<= 1;
if (c & j) bit^= crchighbit;
if (bit) crc^= polynom;
}
}

if (refout) crc=reflect(crc, order);
crc^= crcxor;
crc&= crcmask;

return(crc);
}

bit^= crchighbit; what is that mean?

Thanks for any clue.


bin YE
 
P

pemo

yezi said:
Hi, All:

I am reading the following code:

unsigned long crcbitbybitfast(unsigned char* p, unsigned long len) {

// fast bit by bit algorithm without augmented zero bytes.
// does not use lookup table, suited for polynom orders between
1...32.

unsigned long i, j, c, bit;
unsigned long crc = crcinit_direct;

for (i=0; i<len; i++) {

c = (unsigned long)*p++;

for (j=0x80; j; j>>=1) {

bit = crc & crchighbit;
crc<<= 1;
if (c & j) bit^= crchighbit;
if (bit) crc^= polynom;
}
}

if (refout) crc=reflect(crc, order);
crc^= crcxor;
crc&= crcmask;

return(crc);
}


bit^= crchighbit; what is that mean?

it means:

bit = bit ^ crchighbit

^ means bitwise XOr
 
C

Christopher Benson-Manica

yezi said:
bit^= crchighbit; what is that mean?

bit=bit^crchighbit; /* where ^ is XOR operator */

Your friendly C reference has more information.
 
P

pemo

pemo said:
it means:

bit = bit ^ crchighbit

^ means bitwise XOr

Of course, you can turn it into a logical(ish) operator via: !! e.g.,

bit = !!bit ^ !!crchighbit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,664
Latest member
Phil79581

Latest Threads

Top