Bifalgorithm post · Brisk · Chapter 1

Why does sign-magnitude representation lose one value of expressive power?

Why does sign-magnitude representation lose one value of expressive power? (Brisk · Chapter 1) — "− 127. If you have sharp eyes, you may have noticed a discrep…

Ideas in this flowchart

  • La representación con signo y magnitud pierde un valor porque tiene dos representaciones del cero.
  • El rango de −127 a 127 contiene solo 255 valores distintos, no 256.
  • El esquema de signo y magnitud representa el cero de dos maneras.
  • 00000000 representa el cero.
  • 10000000 también representa el cero, denominado «cero negativo».
  • Usar dos patrones para el mismo valor desperdicia capacidad expresiva.
  • La duplicación del cero hace más complicado el hardware.
  • Normalmente, dos bytes son iguales si todos sus bits coinciden.
  • La igualdad numérica de los dos ceros exige una excepción en la lógica digital.
  • Si los siete bits de la derecha son ceros en ambos bytes, el bit situado más a la izquierda no importa.
Feed/

Why does sign-magnitude representation lose one value of expressive power?

Channel

Brisk

1 page

"− 127. If you have sharp eyes, you may have noticed a discrepancy in the counting. With the sign-magnitude approach, we can hold numbers in the range − 127 to 127. But wait: that’s only 255 different values, not 256! Why did we lose one value of expressive power? The answer is that the sign-magnitude scheme has two ways of representing zero. The bit pattern 00000000 is obviously zero, but so is 10000000 (which you might call “negative zero.”) Using two different patterns to represent the same value is a little wasteful, but the situation is actually worse than that. Having to account for both patterns means that computer hardware using the sign-magnitude scheme is inevitably more complicated. To compare two bytes to see if they’re equal, you’d think we’d just compare each bit position, and if they were all the same, the bytes would be declared equal, otherwise no. Alas, this is no longer quite that simple. The two zero patterns must be considered numerically equal, so our digital logic now has to contain a special case. “To be equal, all the bits have to be the same…oh, but actually not if the right-most seven are all zeroes in both bytes. In that case, it doesn’t matter what the left-most bit contains.” Maddening."

Flowchart preview
Series cover
👍
0
0 comments0 shares

Sign in to view and post comments.