Sir i am not able to understand how right amd left shif work like for 2^n -1 we can use 1<<n but how it work same plz help me to understand this
Not able to understand right amd left shift in bitwise operation
@anuragavm123
Can you please tell me the following things.
what is the binary of 4,8,16,32,64?
what is the binary of 3,7,15,31,63?
100 , 1000 , 10000 , 100000 ,1000000
11 ,111,1111,11111,111111
ok,
so if i shift 1 two time to the left side i get 4 (binary 100). (1<<2)
so if i shift 1 three time to the left side i get 8 (binary 1000). (1<<3)
so if i shift 1 four time to the left side i get 16 (binary 10000). (1<<4)
and so on
so if i want 2^n then i will do (1<<n).
Thank u sir know i am able to understand my doubt is clear
1 Like
you may close your doubt now.