Code logic of replace bit n by m

sir I’m unable to understand why we had done m<<i as this operation will change the number m.

hello @aman.jain.kiet2714

we want to shift m by i positions to the left that why we are doing m<<i.

for example->
if m is 10001 and i is 2
then m<<i will shift m two posiition to the left.
so now it will look something as 1000100 .

we are doing this beuase we want to replace [i…j] bits with m

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.