I would like to left shift a specific no. of ones a specific no. of times. I am trying something like this
//Left shift 3 1's by 5.
int a = 0;
a = 0b(111 << 5) ; //Error : unable to find numeric literal operator 'operator""b'
std::cout << a; //Should be 224
Any suggestions on how I can fix the above ? Ideally I would like something like this
int a = 0;
int noOfOnes = 3;
a = 0b(noOfOnes << 5);
I am not sure how I would accomplish the above in C++ ?
Aucun commentaire:
Enregistrer un commentaire