Sort Bitset

Trying to reverse a binary.
Last edited on
Something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <bitset>
#include <string>

using namespace std;

int main()
{
    bitset<8> b(string("01110001"));
    cout << "original: " << b  << endl;

    for (unsigned i = 0; i < 8; ++i)
        b[i] = b[i] ? 0 : 1;

    cout << "shifted: " << b << endl;
    return 0;
}
Last edited on
How would this work if I only wanted to represent different
Last edited on
Erm, use 7 instead of 8 in the above code...?
Topic archived. No new replies allowed.