Fast exponentiation using bitmasking

sir here in the code below why do you multiply a by a??
why you dont multiply a by 2?
because the bits are like (1,2,4,8,16)and so on

int power(int a,int n)
{
int res{1};
while(n>0)
{
int last_bit=(n&1);
if(last_bit)
res=resa;
a=a
a;
n=n>>1;
}
return res;
}

hey @mzk1994 please share code using ide.codingblocks.com , i can’t read code like this.