jeudi 5 mars 2015

C++ bitwise operations, max value of 12 bit int


So the max value of a 12 bit int should be 4095.



char a, b, c;
int i = (a>>4)<<8 | (b>>4)<<8 | (c>>4);


So the max value that i should be able to be is 4095; however, the value of i often is the max value of a 32 bit integer. How do I make the max value of i be 4095???




Aucun commentaire:

Enregistrer un commentaire