Computer Arithmetic

Which correctly describes +0 and −0 in IEEE 754 floating point?

  1. A−0 cannot be represented; zero is always +0
  2. B+0 and −0 compare unequal, so an if statement can tell them apart
  3. CBoth exist and compare equal, but division can tell them apart
Show answer and explanation

Answer: C. Both exist and compare equal, but division can tell them apart

Because the sign bit is independent, floating point has two zeros differing only in sign, +0 and −0. They compare equal, but some operations differ: 1 ÷ (+0) is +∞ while 1 ÷ (−0) is −∞. −0 appears, for example, when a tiny negative number underflows, preserving which side zero was approached from. Since they compare equal, ordinary comparisons cannot distinguish them; the sign bit must be examined.

  • A. −0 can be represented.
  • B. They compare equal, so ordinary comparisons cannot tell them apart.
  • C. Correct. They compare equal, but operations such as division reveal the difference.
Practice this topic Back to topic

More Computer Arithmetic questions

  1. Which rounding method does IEEE 754 specify as the default?
  2. Rounding to integers with round half to even, what do 2.5 and 3.5 become?
  3. What is the phenomenon called in which subtracting two nearly equal floating-point numbers greatly reduces the significant digits?
  4. For very large x, computing √(x + 1) − √x in floating point suffers catastrophic cancellation. Which rewrite computes it accurately?
  5. In single precision, adding 1 to 100 million (10⁸) leaves the result unchanged at 100 million. Which explains this?