Quantcast
Channel: C++ Do operation on bits of a std::bitset - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by Danil Asotsky for C++ Do operation on bits of a std::bitset

One possible solution is:unsigned long i = arr.to_ulong();i = (i & (i >> 4) & (i >> 8) & (i >> 12)) & 0xf;a = std::bitset<4>(i);

View Article



Answer by 111111 for C++ Do operation on bits of a std::bitset

so long as you know how many bits the target and source are you can do this.std::bitset<16> arr("1100110011001100");std::bitset<4> v ( ((arr ) & (arr>>4 ) & (arr>>8 )...

View Article

Answer by Bo Persson for C++ Do operation on bits of a std::bitset

There is no shortcut with slicing bitsets. Just work your way through the bitsa[0] = arr[0] & arr[4] & arr[8] & arr[12];etc.It can't take the computer long to check 16 bits, however you do it!

View Article

C++ Do operation on bits of a std::bitset

I want to AND 4 4-bits of a std::bitset<16> with each other. I mean:std::bitset<16> arr("1100 1100 1100 1100");I want to AND these 4-bits array.std::bitset<4> a;a= 1100 & 1100...

View Article
Browsing all 4 articles
Browse latest View live


Latest Images