My first thought after seeing that $0000 = 0$ and $1000 = -0$ waste one possible number, was to start negative numbers with $1000 = -1$. So that you just have to write the number flip the first bit and subtract one. It's way easier to see which number is meant, for humans at least. Why isn't it used nor mentioned on Wikipedia as a possible approach?
-
Maybe because of symmetry,you would have $1111=-15$ and $0111=7$ it's much more intuitive to have $1111=-7$ and $0111=7$ – kingW3 Mar 07 '17 at 13:52
-
Possibly helpful: https://en.wikipedia.org/wiki/Two's_complement – Ethan Bolker Mar 07 '17 at 13:52
-
@kingW3 -15 isn't possible with 4 bits. – XBagon Mar 07 '17 at 13:54
-
@XBagon $-1-2-4-8=-15$ though not sure how else would you define it? – kingW3 Mar 07 '17 at 13:55
-
@kingW3 $1111$ ->$ -(0111 + 0001)$ -> $-(1000) = -8$ – XBagon Mar 07 '17 at 14:03
-
Where is the waste? In twos complement $1000=-8$ (not $-0$ as you seem to suggest) With four bit integers the range from $-8$ to $7$ is covered without duplication or gaps. – Jyrki Lahtonen Mar 07 '17 at 14:37
-
@JyrkiLahtonen two's complement works fine. I just think my method is better understandable for humans. – XBagon Mar 07 '17 at 14:38
1 Answers
A different but similar system as you describe is used to store signed integers in computers: Two's complement
The following reason is probably why two's complement is used instead of your system: (from Wikipedia)
The two's-complement system has the advantage that the fundamental arithmetic operations of addition, subtraction, and multiplication are identical to those for unsigned binary numbers (as long as the inputs are represented in the same number of bits and any overflow beyond those bits is discarded from the result). This property makes the system both simpler to implement and capable of easily handling higher precision arithmetic.
So a processor needs only one add instruction, not one for adding two unsigned (non-negative) numbers and one for adding two signed numbers, which would be the case with your system.
- 2,795
-
I know two's complement. That's why i wondered, why would you make it so complicated. – XBagon Mar 07 '17 at 13:56
-
-
Leibniz is often credited with the discovery of binary arithmetic (using base 2), but he, himself, knew that this system had been discovered by the Chinese some 4000 years earlier. See Glaser's History of Binary and other Nondecimal Numeration, http://www.eipiphiny.org/books/history-of-binary.pdf I am getting old and am perhaps in my dotage, but I seem to recall that Leibniz also played around with a base three numeration using a negative. What I recall is not quite what you have in mind, but it did use negative numbers. – Airymouse Mar 07 '17 at 14:40