Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

bitset::operator>>=

Shifts the bits in a bitset to the right a specified number of positions and returns the result to the targeted bitset.

bitset<N>& operator>>=(
   size_t _Pos
);
_Pos

The number of positions to the right the bits in the bitset are to be shifted.

The targeted bitset modified so that the bits have been shifted to the right the required number of positions.

If no element exists to shift into the position, the function clears the bit to a value of 0.

// bitset_op_RSE.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>

int main( )
{
   using namespace std;
   bitset<5> b1 ( 28 );
   cout << "The target bitset b1 is: ( "<< b1 << " )." << endl;

   b1 >>= 2;
   cout << "After shifting the bits 2 positions to the right,\n"
        << " the target bitset b1 becomes: ( "<< b1 << " )." 
        << endl;
}
The target bitset b1 is: ( 11100 ).
After shifting the bits 2 positions to the right,
 the target bitset b1 becomes: ( 00111 ).

Header: <bitset>

Namespace: std

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.