Suppose I have this number eg: 11 which in base 2 is represented as : 1011 . I want to left rotate by N bits this number. So if N = 5 (0101) , then 1011 left rotated by 5 should be 0111 = 7 . Also ,numbers should always be represented on 4 bits.
I tried this approach but can't figure out what the SIZE should be. If I set SIZE to 8 its output will be 353 which is not what I intended.
unsigned int op_lrotate(unsigned int nr1 , unsigned int nr2){
return (nr1 << nr2)|(nr1 >> (SIZE - nr2));
}
int main(){
unsigned int nr1=11;
unsigned int nr2=5;
unsigned int result = op_lrotate(nr1,nr2);
printf("%u",result);
}