Thread: Sorry to start a new thread, but does this work for setting a bit?

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    44

    Sorry to start a new thread, but does this work for setting a bit?

    If I want to set the 31st bit of test_summary to the value of result, does this work? ( note: I simplified the code )


    int test_summary = 0;

    int result = 1;

    test_summary = test_summary | result << 31;

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    #include<stdio.h>
    int main( void )
    {
        int test_summary = 0;
        int result = 1;
        test_summary = test_summary | result << 31;
        printf( "%d\n", test_summary );
        return 0;
    }
    What doesn't work?


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    44
    I am asking if this correct syntax or not for setting the 31st bit of test_summary to the value of result?

    Now I am thinking it should be:
    test_summary = test_summary & result << 31;

    ????
    I am on the right track?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. setting program for start up
    By new_in_c++ in forum Windows Programming
    Replies: 6
    Last Post: 04-30-2011, 10:08 PM
  2. Hijack thread start: shifting a double
    By maha in forum C Programming
    Replies: 6
    Last Post: 07-05-2010, 11:07 AM
  3. Setting SciTE to work with cygwin
    By Witchfinder in forum C Programming
    Replies: 1
    Last Post: 02-21-2009, 04:12 PM
  4. Replies: 72
    Last Post: 01-26-2009, 01:03 PM
  5. URLDownloadToFile dont work in worker thread
    By hanhao in forum Windows Programming
    Replies: 2
    Last Post: 07-02-2007, 12:49 AM