Question

In college, we've seen some general formulas to compute the decimal value a of a binary representation $a_{N-1} \dots a_2 a_1 a_0$ in two's complement, $N$ being the number of bits. For $a \ge 0$ we've seen $a= \sum_{i=0}^{N-2} a_i 2^i$, which seems correct to me if I work it out. But for $a < 0$ our book says $a=-2^{N-1}+\sum_{i=0}^{N-2} a_i 2^i$ and this is where I go wrong.

Can someone explain with an example why this is correct or which formula is right?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top