Bitwise operator: ^ : binary bit « Data Types « C++ Tutorial

Home
C++ Tutorial
1.Language Basics
2.Data Types
3.Operators statements
4.Array
5.Development
6.Exceptions
7.Function
8.Structure
9.Class
10.Operator Overloading
11.Pointer
12.File Stream
13.template
14.STL Introduction
15.string
16.vector
17.list
18.bitset
19.set multiset
20.valarray
21.queue stack
22.deque
23.map multimap
24.STL Algorithms Modifying sequence operations
25.STL Algorithms Non modifying sequence operations
26.STL Algorithms Binary search
27.STL Algorithms Sorting
28.STL Algorithms Merge
29.STL Algorithms Min Max
30.STL Algorithms Iterator
31.STL Algorithms Heap
32.STL Algorithms Helper
C / ANSI-C
C Tutorial
C++
Visual C++ .NET
C++ Tutorial » Data Types » binary bit 
2.13.4.Bitwise operator: ^
#include <iostream>
#include <iomanip>
using std::cout;
using std::endl;
using std::setfill;
using std::setw;

int main() {
  unsigned long red = 0XFF0000UL;      // Color red
  unsigned long white = 0XFFFFFFUL;    // Color white - RGB all maximum

  cout << std::hex;                    // Set hexadecimal output format
  cout << setfill('0');                // Set fill character for output

  unsigned long mask = red ^ white;

  cout << "\n        mask = red  white = " << setw(8<< mask;
  cout << "\n                mask  red = " << setw(8<< (mask ^ red);
  cout << "\n              mask  white = " << setw(8<< (mask ^ white);

  return 0;
}
mask = red ^ white = 0000ffff
                mask ^ red = 00ffffff
              mask ^ white = 00ff0000
2.13.binary bit
2.13.1.Printing an unsigned integer in bits
2.13.2.Display the bits within a byte.
2.13.3.Bitwise operators: Complement, AND, OR
2.13.4.Bitwise operator: ^
2.13.5.Use masks to select or set a particular flag bit
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.