0

Here they mention that " If the word has an even number of bits, the magnitude of the largest negative number that can be represented is twice as large as the largest positive number that can be represented, and vice versa if the word has an odd number of bits."

After re-reading several times, I still don't get it. Could you explain with some example? And Also for the vice versa part.

sofs1
  • 3,834
  • 11
  • 51
  • 89

1 Answers1

2

As it says in the link you posted, "The rightmost bit represents (−2)^0 = +1, the next bit represents (−2)^1 = −2, the next bit (−2)^2 = +4 and so on, with alternating sign."

If the bits alternate in sign, and the first bit is a positive number, then every even bit will result in a negative number. If this even left-most bit is set to 0, the number would be positive, however, the absolute value would be half as much as the previous number.

For example:

0101 = 5 because it's (-2)^0 + (-2)^2 = +1+4

1010 = -10 because it's (-2)^1 + (-2)^3 = -2-8

However, if we were limited to 3 bits, we would have

010 = -2 because it's (-2)^1 = -2

101 = 5 because it's (-2)^0 + (-2)^2 = 1 + 4 = 5

Essentially, in base-2 the largest negative number you can reach is one where every even bit is set to 1, and every odd bit is set to 0. And the highest positive number is one where the opposite is true.

If the total number of bits allowed is even, then setting the left most even bit to 1 would yield a negative number at least twice as large as the largest positive number (as any positive number would leave that left most bit set to 0). And the opposite is true with an odd number of bits.

Community
  • 1
  • 1
Ali Elgazar
  • 777
  • 2
  • 12
  • 26
  • @user3705478 Anytime! If the answer sufficed can you accept? :D – Ali Elgazar Oct 03 '18 at 15:25
  • Could you help me understand “Two's complement arithmetic, on the other hand, forms the negation of x by subtracting x from a single large power of two that is congruent to +0” from https://en.m.wikipedia.org/wiki/Signed_number_representations. – sofs1 Oct 04 '18 at 04:14
  • @user3705478 Sure! Two's complement is basically a process of acquiring the negative value of a number through it's binary value. Now as you may already know, the left-most bit in a signed binary representation indicates that the number is negative. For example, 0001 represents 1, however 1111 represents -1. The way you acquire the negative number is basically, you flip all the bits to their opposite value, then you add one to the result. Let's walk through the above example. we flip the bits in 0001 (1 in dec) and it becomes 1110, then we add one and it becoems 1111 (-1 in dec). – Ali Elgazar Oct 04 '18 at 19:15
  • I get the part you explained. But I don't get "subtracting x from a single large power of two that is congruent to +0". What is meant by that?? – sofs1 Oct 04 '18 at 19:31