Thread: |= operator

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    151

    |= operator

    I was reading a game programming book, and I came across an operator that I never say before, it was
    Code:
     |=
    was does that symbolize?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    It means set the variable to itself or'd with the operand. In other words:
    Code:
    int x = 1;
    x |= 6; // set x equal to x or'd with 6
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    its shorthand for x = x | 6;

    Just like x += 6 is shorthand for x = x + 6
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why can't my perceptron learn correctly?
    By yann in forum C Programming
    Replies: 25
    Last Post: 10-15-2010, 12:26 AM
  2. |= operator in C++
    By sunny_master_07 in forum C++ Programming
    Replies: 2
    Last Post: 02-04-2009, 08:28 AM
  3. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-06-2003, 11:51 PM