I know that mathematically the k-V analog input on an A to D converter could be converted to the digital code of $\dfrac{k(2^n-1)}{VDD}$. But I really don't understand where it comes from and the logic behind it. Any help would be appreciated.