Sort Bitset
| AtomicX (3) |
|
|
Trying to reverse a binary.
|
|
Last edited on
|
| modoran (1101) |
|
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
|
| AtomicX (3) |
|
|
How would this work if I only wanted to represent different
|
|
Last edited on
|
| Zhuge (2880) |
|
|
Erm, use 7 instead of 8 in the above code...?
|
|
|
Topic archived. No new replies allowed.