its two's complement because you take the power of 2 that is 1 above the range of the bits. and then subtract the number from it for its two's complement, which due to overflows is the same as inverting every bit and adding 1

]]>Ricky wrote:

After a great amount of confusion i've hypothesized that they use the regular binary system to store positive values, and two's complement numbers for negative values.

Two's complement is "regular binary" for positive values. I'm not certain if that's what you were trying to say.

by 'regular binary' i meant place value, as in 1010 = 1*2^3 + 0*2^2 + 1*2^1 + 0*^0 = 12d

What i really think my book is doing is using the ordinary binary system for positive numbers (as in, 1010 = 12d) and using two's complement for negative numbers. I was actually able to prove that there is no overlap so there is no ambiguity between the two.

we are using an online text for this course, and its accesible from anywhere:

http://webster.cs.ucr.edu/AoA/DOS/pdf/0_AoAPDF.html

if you click on chapter 1 and go to the pages 13 of the pdf (not of the actual page numbers) you can find the part on signed numbers and on the next page they do positive to negative conversions.

The reason i think they're using 'place value binary' for positive numbers and 'two's complement' for negatives is because supposedly, you can calculate a numbers negative by using NOT and adding 1. They begin with 5 written as 0101 and then write -5 as 1011. 1011 = 11d which by my understanding, is how we write positive 5 in two's complement form.

also, that pdf never actually told me what two's complement meant and i'm currently under the impression that if x is the value you want to represent (who's binary form has n bits) then

x + complement = 2^n

and we write x in two's complement form by writing 'complement' in binary form.

Thats my understanding of the subject. Care to point out where i'm going wrong, if anywhere?

]]>then lets do it in decimal.

-0485 = 10000-0485 = 9515.

0785+9515 = (1)0300 = 300. the correct result for 785-485.

-4 1100

+5 0101

== ====

1 10001

-5 1011

+4 0100

== ====

-1 1111

If there are 5 digits (in these examples) in the answer, the leftmost digit is ignored.

]]>example: 4 bit signed integers:

6 = 0110. -6 = !6+1 = 1001+1 = 1010

now if we add them together we get

0110+1010 = (1)0000. since the 1 is lost in overflow we get 0. the correct result

another example:

5 = 0100. -7 = 1001

add them together you get 1101 which is -2. the correct result.

]]>After a great amount of confusion i've hypothesized that they use the regular binary system to store positive values, and two's complement numbers for negative values.

Two's complement is "regular binary" for positive values. I'm not certain if that's what you were trying to say.

In two's complement and ignoring the first bit, the lowest number is always represented by 000....1, and the highest number is represented by 11111...1. This is true for positive and negative numbers.

01111111...1 is the highest positive value. 0111 is 7.

11111111...1 is the highest negative value. 1111 is -1.

00000000...1 is the lowest positive value. 0001 is 1.

10000000...0 is the lowest negative value. 1000 is -8.

From there, you just interpolate. For each bit you add on to (1/0)00000, simply add 1 to the number. This means:

0001 = 1

0010 = 2

0011 = 3

While:

1000 = -8

1001 = -7

1010 = -6

And so on. Now the real question is why do we use this system?

]]>I'm reading about how a given computer system stores negative numbers, and they are not being very clear. After a great amount of confusion i've hypothesized that they use the regular binary system to store positive values, and two's complement numbers for negative values.

Supposedly, you can take the negative of a number by using NOT and adding 1

take 3

0011

NOT

1100

add 1

1101 this represents -3?

but that gives us 13, which if i'm not mistaken is the complement of 3, not -3.

is this correct? we store negative values by storing their absolute value in two's complement form?

]]>