Kleuskes & Moos
5/7/2011 4:51:00 PM
On May 7, 6:45 pm, fl <rxjw...@gmail.com> wrote:
> On 7 mai, 12:37, fl <rxjw...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > Hi,
>
> > I do not understand the index variable 'j' function below. How deos j
> > control to end of the for loop?
> > It cycles 8 times from step tracking. When does j equal 0, it ends the
> > loop. I do not understand why it ends when j==0.
>
> > Thanks in advance
>
> > .............
> > for (j=0x80; j; j>>=1) {
> > bit = crc & crchighbit;
> > crc<<= 1;
> > if (c & j)
> > crc|= 1;
> > if (bit)
> > crc^= polynom;
>
> > }- Masquer le texte des messages précédents -
>
> > - Afficher le texte des messages précédents -
>
> The second item 'j' in the for loop means it is non-zero. This non-
> zero as the termination criteria? Thanks.
j <-- 0b10000000
While j is not 0 (any non-zero value i interpreted as true)
Shift j one position to the right.
The single one will then be shifted out after 8 iterations, resulting
in j=0 (i.e. false) and the loop stops.