valarray::operator>>=
Right-shifts the bits for each element of a valarray operand a specified number of positions or by an element-wise amount specified by a second valarray.
valarray<Type>& operator>>=(
const valarray<Type>& _Right
);
valarray<Type>& operator>>=(
const Type& _Right
);
Parameters
- _Right
The value indicating the amount of right shift or valarray whose elements indicate the element-wise amount of right shift.
Return Value
A valarray whose elements have been shifted right the amount specified in _Right.
Remarks
Signed numbers have their signs preserved.
Example
// valarray_class_op_rs.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
int main( )
{
using namespace std;
int i;
valarray<int> vaL ( 8 ), vaR ( 8 );
for ( i = 0 ; i < 8 ; i += 2 )
vaL [ i ] = 64;
for ( i = 1 ; i < 8 ; i += 2 )
vaL [ i ] = -64;
for ( i = 0 ; i < 8 ; i++ )
vaR [ i ] = i;
cout << "The initial operand valarray is: ( ";
for ( i = 0 ; i < 8 ; i++ )
cout << vaL [ i ] << " ";
cout << ")." << endl;
cout << "The _Right valarray is: ( ";
for ( i = 0 ; i < 8 ; i++ )
cout << vaR [ i ] << " ";
cout << ")." << endl;
vaL >>= vaR;
cout << "The element-by-element result of "
<< "the right shift is the\n valarray: ( ";
for ( i = 0 ; i < 8 ; i++ )
cout << vaL [ i ] << " ";
cout << ")." << endl;
}
The initial operand valarray is: ( 64 -64 64 -64 64 -64 64 -64 ).
The _Right valarray is: ( 0 1 2 3 4 5 6 7 ).
The element-by-element result of the right shift is the
valarray: ( 64 -32 16 -8 4 -2 1 -1 ).
Requirements
Header: <valarray>
Namespace: std