Velocity Reviews > What is the sentence mean?Thanks

# What is the sentence mean?Thanks

yezi
Guest
Posts: n/a

 11-28-2005
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

pemo
Guest
Posts: n/a

 11-28-2005

"yezi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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

Christopher Benson-Manica
Guest
Posts: n/a

 11-28-2005
yezi <(E-Mail Removed)> wrote:

> bit^= crchighbit; what is that mean?

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

Your friendly C reference has more information.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.

pemo
Guest
Posts: n/a

 11-28-2005

"pemo" <(E-Mail Removed)> wrote in message
news:dmfeqi\$smk\$(E-Mail Removed)...
>
> "yezi" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>> 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

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

bit = !!bit ^ !!crchighbit

 Thread Tools

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Matt Java 11 08-16-2010 09:05 AM Geo VHDL 6 02-12-2006 04:07 AM Geo VHDL 0 02-08-2006 06:39 AM Jluis VHDL 3 05-05-2004 10:07 AM Ian Pilcher Java 0 12-12-2003 01:18 AM

Advertisments