can anyone explain the logical behind clear the last bits I am bit confused with the index position and actual bit that we want to clear it . Please explorate it completely.
clearLastbits form the bit manipulation
@Vikaspal You will best understand by watching the video again. It is well explained there.
When you have to find the ith bit from last then you use n&(1<<i-1) only.
In clearing range of bits we are using a fact that we have to shift each bit of 11111… to left so that we have i zeros on the right hand side and then we can get the required mask.
Watch the video again…mention the part of the video which you are unable to understand.