samedi 25 août 2018

Shifting 1001 certain value gives a different result than expected

I am doing the following. I would like to shift 1001 to the left

int a = 0;
a = (1001 << 2);
std::cout << a; //Gives 4004

I was expecting it to be in binary 100100 which is 36. Why am I getting 0000111110100100?

Aucun commentaire:

Enregistrer un commentaire