Hi what is the formula for an $n$ bit twos complement to decimal.. for example from $ n$ bit unsigned to decimal the formula is.. $\sum_{i=0}^{n-1} a_i 2^i$
from signed magnitude to decimal is $(-1)^{a_{n-1}}$ $\sum_{i=0}^{n-2} a_i 2^i$
i need from twos complement to decimal formula please these above are correct
If the number is positive, the lead bit is zero and your unsigned expression applies. If the number is negative, treat the number as positive and apply your unsigned expression, getting a value of $m$. Then the answer is $m-2^n$. You can combine them into $\left(\sum_{i=0}^{n-2} a_i 2^i\right)-a_{n-1}2^{n-1}$