   What does this do?
  Hello I apologise for the no doubt "newby" question, I keep coming across (while learning how to use SDL and other Graphic Orientated things) the '|' character (guessing its a bitwise OR?) but I just can't comprehend what this actually does, was hoping someone could explain this to me as the tutorials etc that I have read about it don't really tell me what its doing in SDL. EGscreen = SDL_SetVideoMode (640, 480, 16, SDL_SWSURFACE | SDL_DOUBLEBUF);I'm having fun going through the tutorials for SDL and seeing what gets produced, understanding the majority of it, but at these bits i'm just copying and pasting with the thought that "well I don't know what it does, but it works". Thank you. P.S I'm doing it in C++.   
  Yes, it is a bitwise or. If you look at those constants (SDL_SWSURFACE, SDL_DOUBLEBUF and like) in binary, you'll see that usually they have only one bit set. Bitwise or results in a variable that has all those bits set. Say, one was binary 0001 and the other was 0100, then bitwise or would produce 0101. The function then uses bitwise AND to check whether certain bits are set, and makes appropriate decision.It's basically a way to pass many boolean parameters with one variable.   ;  In that instance it is used to combine various options in a space efficient way - read up on bit masks.   ;  Yes, it is the bit-wise OR operator.  Basically it takes a binary number on the left and combines it with the bits of a binary number on the right.  However, it combines the two binary numbers in a special way.  It basically says if bitx is a 1 for either the left or right hand number, than the result's bitx is 1.  If bitx is 0 for both the left and right hand number, than the results bitx is 0.  Below are some examples.001100 | 010100 = 011100010101 | 101010 = 111111100100 | 011110 = 111110Using the bitwise OR operator, we can "combine" parameters together.  Consider the following example:enum AnEnum{    OPTION1 = 1,  // binary: 000001    OPTION2 = 2,  // binary: 000010    OPTION3 = 4,  // binary: 000100    OPTION4 = 8,  // binary: 001000    OPTION5 = 16, // binary: 010000    OPTION6 = 32  // binary: 100000};int resultA = OPTION1 | OPTION3; // binary: 000101int resultB = OPTION5 | OPTION6; // binary: 110000int resultC = OPTION1 | OPTION2 | OPTION4 | OPTION6; // binary: 101011In resultA we said we wanted both OPTION1 and OPTION2 by using the | operator.  This combined them together in binary form.  The same thing was done for resultB and resultC.  I don't know how SDL_SWSURFACE and SDL_DOUBLEBUF are defined, but it's something similar to the above where each one is given a certain number (the number is important when in binary form because we want to combine the bits).[edit]ninja'd by ertyqwer and AntiRush...   ;Quote:Original post by MikeTacularYes, it is the bit-wise OR operator.  Basically it takes a binary number on the left and combines it with the bits of a binary number on the right.  However, it combines the two binary numbers in a special way.  It basically says if bitx is a 1 for either the left or right hand number, than the result's bitx is 1.  If bitx is 0 for both the left and right hand number, than the results bitx is 0.  Below are some examples.001100 | 010100 = 011100010101 | 101010 = 111111100100 | 011110 = 111110Using the bitwise OR operator, we can "combine" parameters together.  Consider the following example:*** Source Snippet Removed ***In resultA we said we wanted both OPTION1 and OPTION2 by using the | operator.  This combined them together in binary form.  The same thing was done for resultB and resultC.  I don't know how SDL_SWSURFACE and SDL_DOUBLEBUF are defined, but it's something similar to the above where each one is given a certain number (the number is important when in binary form because we want to combine the bits).[edit]ninja'd by ertyqwer and AntiRush...Thank you for all your replies, but thank you for this as well along with the example, thats basically what I wasn't understanding WHY it was used, how does one know that certain binary results are needed and to get them with doing '|'. That makes a whole more sense, and its strange I couldn't find a tutorial explaining it like this (I knew that it would go 1001 | 0100 = 1101, but in terms of why (especially in relation to games/graphics) it was used. Cheers! I shall print that out and keep it around to refresh my memory if needed. 