Negatives...by (Login Mikrondel)
Let's suppose we're talking about 16-bit numbers.
To get a signed number, you take an ordinary 16-bit binary number (0-65535), and "rename" all numbers from 32768 up to 65535 as numbers from -32768 to -1, keeping them in the same order.
So, rather than calling 10000000 00000000 by the name "32768", instead you call it "-32768". Rather than calling 11111111 11111111 by the name "65535", you call it "-1".
This is the system used on most computers (including all PCs) because it has many advantages. For one thing, adding and subtracting numbers is always done the same way, whether you want the number to be signed or unsigned.
As other people have said, all the negatives now have their most significant bit as 1; and to negate a number all you need to do is flip all the bits, and add 1. (But x86 processors have the NEG instruction that does that for you.)
What happens when you try to take the negative of -32768? Find out for yourself.
|Response Title||Author and Date|
|I found an interesting story about negative number representations||qbguy on Jan 3|