I didnt understand how to find B?

b=(1<<i)-1;

can you explain me this.
specifically what happens when we do -1 ?

(1<<i) generates return 2^i so if we subtract 1 we get 2^i -1 and this number would have all the bits as one of example in i =2 , 1<<i will be 4 and 4-1 = 3 and 3’s binary representation is 11 similarly when i = 3 we will get 7 whose binary representation is 111.