Difference between inclusive-or and or

Discussion in 'Mac Programming' started by djohnny545, Jul 2, 2010.

  1. djohnny545 macrumors newbie

    Jul 2, 2010

    I recently read that Objective C 2.0 uses '|' to represent the inclusive-or bit operator and '^' to represent the or operator.

    Could someone please explain the difference between inclusive-or and or?

    Thanks very much!
  2. JoshDC macrumors regular

    Apr 8, 2009
    | is inclusive OR (usually just OR) and gives 1 if either compared bits are 1.

    ^ is exclusive OR (or XOR) and differs from inclusive or in that if both compared bits are 1 the result is 0.
  3. djohnny545 thread starter macrumors newbie

    Jul 2, 2010

Share This Page