#include <iostream>

int main()
{
	const int wrap = 255;

	int x = 1;
	
	std::cout << "X = " << x << std::endl;
	while( x < 256 ) 
	{
		x <<= 1;
		std::cout << "X = " << x << std::endl;
	}
	
	if( x >= 256 ) //the next shift
	{
		x -= wrap;
		std::cout << "X wrapped!" << std::endl << "X = " << x << std::endl;
	}
	return 0;
}