#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKaW50IG1haW4oKQp7Cgljb25zdCBpbnQgd3JhcCA9IDI1NTsKCglpbnQgeCA9IDE7CgkKCXN0ZDo6Y291dCA8PCAiWCA9ICIgPDwgeCA8PCBzdGQ6OmVuZGw7Cgl3aGlsZSggeCA8IDI1NiApIAoJewoJCXggPDw9IDE7CgkJc3RkOjpjb3V0IDw8ICJYID0gIiA8PCB4IDw8IHN0ZDo6ZW5kbDsKCX0KCQoJaWYoIHggPj0gMjU2ICkgLy90aGUgbmV4dCBzaGlmdAoJewoJCXggLT0gd3JhcDsKCQlzdGQ6OmNvdXQgPDwgIlggd3JhcHBlZCEiIDw8IHN0ZDo6ZW5kbCA8PCAiWCA9ICIgPDwgeCA8PCBzdGQ6OmVuZGw7Cgl9CglyZXR1cm4gMDsKfQ==