Replacing Bits in N by M

sir ,in this video sir has given an example n=15,and i=1 ,j=3and m=2, and after replacing the answer becomes 5 how, please tell me

hi @Abhishmu5 let us assume that size of int is 8 bits(for our convenience)
n =15 is 00001111
m = 2 is 10
now, j = 3 and i = 1
this will make n as
00001111 (n before)
76543210 (index)
00000101 (n after)
bits from range 1- 3 were replaced with “010”
and decimal rep of 101 is 5

Please mark the doubt as resolved if it is clear now.

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.