C/C++

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • What is the sentence mean?Thanks

    3 answers - 762 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    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
    132.
    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; j1) {
    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
  • No.1 | | 880 bytes | |


    "yezi" <ye_line@hotmail.comwrote in message
    news:1133198789.981261.185160@
    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
    132.

    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; j1) {

    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 X

  • No.2 | | 189 bytes | |

    yezi <ye_line@hotmail.comwrote:
    bit^= crchighbit; what is that mean?
    bit=bit^crchighbit; /* where ^ is XR operator */
    Your friendly C reference has more information.
  • No.3 | | 1606 bytes | |


    "pemo" <usenetmeisterr@gmail.comwrote in message
    news:dmfeqi$smk$1@news.ox.ac.uk

    "yezi" <ye_line@hotmail.comwrote in message
    news:1133198789.981261.185160@
    >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
    >132.
    >>

    >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; j1) {
    >>

    >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 X

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

    bit = !!bit ^ !!crchighbit

Re: What is the sentence mean?Thanks


max 4000 letters.
Your nickname that display:
In order to stop the spam: 3 + 2 =
QUESTION ON "C/C++"

EMSDN.COM