
Bitwise & operator tricky question
Quote:
>Does anyone know what the following does:
>for (a = 1; a < 100; a++)
> {
> a =& (a-1);
> }
Yes, it generates error messages about different levels of indirection or a
syntax error, I suppose. If you meant a &= (a-1) then it loops forever, since
the first pass will set a to zero, then it goes to 1, then to zero etc.
Quote:
>I know what the & operator does, but what is special about doing it to an
>integer and that same integer minus 1?
>Some kind of pattern.
You will have to state your question properly if you expect to receive a
sensible answer.
--
Hypertext C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-FAQ ftp: ftp://rtfm.mit.edu, C-FAQ Book: ISBN 0-201-84519-9
Try "C Programming: A Modern Approach" ISBN 0-393-96945-2
Want Software? Algorithms? Pubs? http://www.infoseek.com