Questions tagged [std-bitset]

A C++ container class similar to an array but containing only bits, included in the library.

A C++ container class similar to an array but containing only bits, included in the <bitset> library. It has a fixed length specified at compile time via a template parameter.

It allows for random access and can be manipulated with standard logic operators.

A reference is available.

109 questions
-2
votes
1 answer

Why bitset order looks like reversing per byte

I'm having trouble when I want to read binary file into bitset and process it. std::ifstream is("data.txt", std::ifstream::binary); if (is) { // get length of file: is.seekg(0, is.end); int length = is.tellg(); is.seekg(0, is.beg); …
tom
  • 1
  • 1
-2
votes
2 answers

Structure padding with union members of std::bitset

After I had solved my issue to this question I went on to expand this version of my code to incorporate the unions of the data fields from my previous template versions with this version and I have this so far: main.cpp #include #include…
Francis Cugler
  • 7,788
  • 2
  • 28
  • 59
-3
votes
3 answers

c++ XOR between bitsets

std::bitset <1> a1; std::bitset <1> a2; a1 = std::bitset<1> (0); a2 = std::bitset<1> (1); std::bitset<1> b = (a1 ^= a2) This results in b = 1 which is fine but modifies also a1, which after the XOR operation becomes: a1 = 1 Why is this…
rebrid
  • 430
  • 8
  • 27
-5
votes
1 answer

Converting string containing binary to unsigned and signed ints

I want to write program (at the moment I don't have any code), which should do the following: Take from user string containing binary number, Convert it to unsigned int and signed int, Return the result to the user. How can I implement the second…
1 2 3 4 5 6 7
8