2020 Practice Exam 1 MCQ

score

Question 4:

In a certain computer program, two positive integers are added together, resulting in an overflow error. Which of the following best explains why the error occurs?

  • My answer: D- The program cannot represent integers; the integers are converted into decimal approximations, leading to rounding errors.
  • Correct answer: C- The program can only use a fixed number of bits to represent integers; the computed sum is greater than the maximum representable value.
  • Corrections: Overflow errors occur when an arithmetic operation results in a value outside the range of numbers that can be represented by a fixed number of bits. While fractions are sometimes represented by decimal approximations that are subject to rounding errors, integers are not. Sometimes, when adding two binary numbers we can end up with an extra digit that doesn’t fit. This is called an overflow error.