for getting the ith bit , we have to write this one n & (1 << i ). when we are reading the last bit in the right as 0th bit .
in books of Narasimha book is n & (1 << (i - 1) is given . because he is assuming the last bit in the right as 1st bit.
same thing i got also on geeks for geeks
because consider a example n=15
13=1101 here the first bit is 1
2nd bit is 0
3rd bit is 1
4th bit is 1.
is there any rule to reading the last bit as oth bit or 1st bit ?