Using the << operator to shift a value from the lower 16 bits of a int into the upper 16 bits. - C++ Operator

C++ examples for Operator:Bit Operator

Description

Using the << operator to shift a value from the lower 16 bits of a int into the upper 16 bits.

Demo Code

#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    const int maskBits{ 16 };
    int leftShifted{ 0x00001010 << maskBits };
    cout << showbase << hex;
    cout << "Left shifted: " << leftShifted << endl;

    return 0;/* ww  w .ja v  a2 s  . c om*/
}

Result


Related Tutorials