Computer Arithmetic

In single precision, adding 1 to 100 million (10⁸) leaves the result unchanged at 100 million. Which explains this?

  1. A100 million cannot be represented in single precision, so the result is NaN
  2. BWith only about seven digits, the 1 is lost in rounding
  3. CThe add instruction is designed to skip computations on large numbers
Show answer and explanation

Answer: B. With only about seven digits, the 1 is lost in rounding

Single precision has about seven significant digits, and near 100 million the spacing between representable numbers is 8. 100,000,001 falls between two representable values and rounds to the nearest, 100 million, so the 1 vanishes. Losing the smaller operand's information when adding numbers of different magnitudes is called absorption. When summing many small values, adding the smallest first or using compensated summation helps. 100 million is representable and does not become NaN.

  • A. 100 million is representable and does not become NaN.
  • B. Correct. The spacing near 10⁸ is 8, so 1 is rounded away.
  • C. The add instruction does not skip any computation.
Practice this topic Back to topic

More Computer Arithmetic questions

  1. What is the purpose of Kahan (compensated) summation when adding many floating-point numbers?
  2. What is the advantage of computing a × b + c with an FMA (fused multiply-add) instruction?
  3. What is the main reason bfloat16 is used for AI training?
  4. When training neural networks in FP16 (half precision: 1 sign, 5 exponent, 10 significand bits), which problem tends to arise and is countered by scaling up the loss (loss scaling)?
  5. What is the largest finite value representable in FP16 (1 sign, 5 exponent bits with bias 15, 10 significand bits)?