Computer Arithmetic

Why are monetary amounts often handled as integers in the smallest unit (one yen or one cent) rather than as binary floating point?

  1. AFloating point cannot represent large amounts of money at all
  2. BIntegers always use less memory than floating-point numbers
  3. CDecimal fractions are inexact in binary, causing errors
Show answer and explanation

Answer: C. Decimal fractions are inexact in binary, causing errors

Decimal 0.1 and 0.01 are not exact in binary floating point and are stored as rounded approximations. Repeated additions accumulate error, so totals can end up a yen or cent off. Since money tolerates no such error, calculations use integers counting the smallest unit, or decimal formats. Floating point can approximate large amounts, and memory usage is not the reason.

  • A. Large values can be approximated; the issue is error.
  • B. Memory usage is not the main reason.
  • C. Correct. Decimal fractions are not exact, and the errors are unacceptable.
Practice this topic Back to topic

More Computer Arithmetic questions

  1. In mixed-precision AI training, why are master weights kept in FP32 while most computation is done in FP16 or bfloat16?
  2. In unsigned fixed point with the low 4 of 8 bits as the fraction, what value does the bit pattern 0011 1000 represent?
  3. Which three parts make up an IEEE 754 floating-point number?
  4. How are the bits of an IEEE 754 single-precision (32-bit) number allocated among sign, exponent and significand?
  5. In IEEE 754 double precision (64-bit), how many bits are the exponent and significand?