Thread: what does this code do?

  1. #1
    Registered User
    Join Date
    Jun 2007

    what does this code do?

    I'm looking at some code I'm trying to use out of a book, but there are a couple portions of it I don't understand.

    for (ntmp = ntps; ntmp; ntmp >>= 1) {
             m <<= 1;

    mid=(1+ir) >> 1;
    Specifically, what does the >>= and <<= operators mean?


    for (;;) {
            ----Inner loop code----
    If someone could explain what exactly these three sections of code are doing, it would be appreciated.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    >> and << is "shift right operator" and "shift left operator" respectively. That is multiply by 2 or divide by 2 to the power of y where y is what's on the right of the operator >>.

    The >>= operator is the same, but short hand for x = x >> y;

    The for(; is an infinite loop (of course, the loop may have code inside it that breaks the loop itself).

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM