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

This is a discussion on Sorry to start a new thread, but does this work for setting a bit? within the C Programming forums, part of the General Programming Boards category; If I want to set the 31st bit of test_summary to the value of result, does this work? ( note: ...

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

    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
    18
    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, 11:08 PM
  2. Hijack thread start: shifting a double
    By maha in forum C Programming
    Replies: 6
    Last Post: 07-05-2010, 12:07 PM
  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, 01:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21