I do not understand why this gives me the same answer:
long long a = 3265917058 >> 24;
std::cout << a << std::endl;
long long ip = 3265917058;
long long b = ip >> 24;
std::cout << b << std::endl;
but this is not so:
long long a = (3265917058 << 16) >> 24;
std::cout << a << std::endl;
long long ip = 3265917058;
long long b = (ip << 16) >> 24;
std::cout << b << std::endl;
Update: I want a 32-bit shift, but how can a 32-bit shift shift a number that is too large for the int variable? Update2: My answer is to make unsigned int ip. Then everything will be fine.
Stals source
share