Hi there.
I was wondering if someone could explain the example on page 66 for me, cause I don't understand it
On page 66 it says that the number 5 in its full binary representation is represented as:
000000000000000000000000000000101
I understand that, but then it says that -5 is represented as:
111111111111111111111111111111011
This I don't understand. How is the above representation equal to -5? Isn't this calculated as 1*(2^0) + 1 * (2^1) + 0 * (2^2) (calculating from left to right) for which the sum would result in a huge number and not -5, or what am I missing here?
And then, continueing from the example, these two representations get summed:
000000000000000000000000000001010
+ 111111111111111111111111111111011
= 1000000000000000000000000000000101
Where does the extra 1 to the left come from, and how should I interpret that? Obviously, the way I understood it, I would calculate this to a decimal value this way:
1*(2^32) + ... 1*(2^2) + 0 * (2^1) + 1*(2^0)
Which would give in decimal:
4294967296 + 4 + 1 = 4294967302 which obviously is not correct, as this is not the same as subtracting 5 from 10.
I'm sorry if this is a stupid question, I just started on programming, and I really can't see what I've missed here.
Love the book by the way, it is awesomely well written.