Thread: bit value generation doubt

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2009
    Location
    US of A
    Posts
    305

    bit value generation doubt

    I came across this link on how to generate the bitwise represenation of any int , char on one of the forums.

    showbits

    The logic that the program uses is

    [insert]
    Code:
    void bits_uint(unsigned int value)
     {
        unsigned int bit;
        for ( bit = /* msb */(~0U >> 1) + 1; bit > 0; bit >>= 1 )
        {
          putchar(value & bit ? '1' : '0');
        } 
       putchar('\n');
    }
    In the for loop the condition that the program uses is

    for ( bit = /* msb */(~0U >> 1) + 1; bit > 0; bit >>= 1 )

    What does this imply

    bit >>= 1(greater than , greater than equal to ???????????????)


    If i understand it now its supposed to mean

    bit = bit >> 1;
    Last edited by roaan; 08-07-2009 at 01:49 PM. Reason: understood the meaning

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-10-2005, 10:53 AM
  2. porting application from 32 bit to 64 bit error
    By gandalf_bar in forum Linux Programming
    Replies: 1
    Last Post: 09-14-2005, 09:20 AM
  3. Bit processing in C
    By eliomancini in forum C Programming
    Replies: 8
    Last Post: 06-07-2005, 10:54 AM
  4. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM
  5. bit conversions
    By wazilian in forum C Programming
    Replies: 4
    Last Post: 10-25-2001, 08:59 PM