31 in base 2 is 3*2+1=7. Digits retain their meanings from base 10, but place values change.
Likewise AB in base 10 is A*10(=10*10)+B(=11)=111.