Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.

How do omputers negate binary?

Computers are only able to add, if they want to substract they have to negate one of the summands. But there is my question: how can computer do that by avoiding that 0 gets to -1? Have computers two 0s (+0 and -0)?

000 -4

001 -3

010 -2

011 -1

100 +0

101 +1

110 +2

111 +3

Problem: 0 turns to -1

000 -3

001 -2

010 -1

011 -0

100 +0

101 +1

110 +2

111 +3

Problem: -0 plus 1 = +0

1 Antwort

Relevanz
  • Dan
    Lv 4
    vor 2 Jahrzehnten
    Beste Antwort

    Computers represent signed integers using something called twos-complement arithmetic. For numbers of a certain size, the first bit is reserved for negative numbers. A negative number is represented as the one that, when added to it's positive, would give zero.

    So in your example (where numbers are 3 bits long):

    -1 is represented as 111 because 111 + 001 = 000 (ignoring the carry to the nonexisting 4th bit).

    -2 is represented as 110 because 110 + 010 = 000.

    You can think of it like an odometer. To see how to represent the positive number n, it's like running the odometer forward n units starting from zero. To see the negative number, run it backward n units starting from zero.

    Quelle(n): Computer science degree.
Haben Sie noch Fragen? Jetzt beantworten lassen.