Tarek
Tarek

Reputation: 1090

Bitwise operations between an integer and an array of bits

Suppose I have a c++ array of bits, ones and zeros, and I want to have it bitwise XORed with an integer number, and get the result as an integer. What is the fastest way to do so?

Upvotes: 0

Views: 382

Answers (1)

Mark B
Mark B

Reputation: 96243

Assuming that you mean a std::bitset and assuming that it would fit into an unsigned long, then unsigned long result = your_bits.to_ulong() ^ your_int;

Upvotes: 4

Related Questions