A programmer writes `if (0.1 + 0.2 == 0.3)` in a language using IEEE 754, and the condition evaluates to false. The most accurate explanation is:
AThe processor has a bug in its floating-point arithmetic unit that affects certain decimal fractions
B0.1, 0.2, and 0.3 cannot be represented exactly in binary, so 0.1 + 0.2 produces a slightly different approximation than the stored value of 0.3
CFloating-point addition is not commutative, so the result depends on operand order
DThe equality operator is inherently unreliable for all numeric comparisons in IEEE 754
This is the fundamental consequence of finite-precision binary representation. 0.1 in binary is a repeating fraction (like 1/3 in decimal), so the stored value is an approximation. Adding the approximations of 0.1 and 0.2 produces a slightly different value than the stored approximation of 0.3. The error is inherent to the representation — not a hardware bug. Floating-point addition is commutative (option C is false). The correct practice is to check approximate equality: `abs(a - b) < epsilon`.
Question 2 Multiple Choice
In IEEE 754 single-precision format, the exponent field stores the value 130. What actual exponent does this represent?
A130 — the stored value is used directly as the exponent
B3 — the actual exponent is the stored value minus the bias of 127
C2 — the stored exponent uses two's complement, so 130 encodes 2
D257 — the bias is added to the stored value to get the actual exponent
IEEE 754 uses biased (excess-127) exponent encoding: actual exponent = stored value − 127. A stored exponent of 130 represents actual exponent 130 − 127 = 3, meaning the number is ±1.mantissa × 2³. The bias avoids needing two's complement for the exponent field and makes floating-point magnitude comparison possible using integer comparison hardware. Option D inverts the relationship: you subtract the bias from the stored value, not add it.
Question 3 True / False
In IEEE 754 single-precision, the leading 1 of the significand is implicit and not stored, giving 24 bits of effective precision from only 23 stored mantissa bits.
TTrue
FFalse
Answer: True
In binary scientific notation, every normalized nonzero number has the form 1.xxx...x × 2^e — the leading digit is always 1 because 1 is the only nonzero binary digit. Since this leading 1 is guaranteed to be present in any normalized number, it need not be stored. The 23 mantissa bits store only the fractional part. When the number is reconstructed, hardware implicitly prepends the 1, giving 24 bits of significand precision. This implicit leading bit is a free precision bonus inherent to the binary format.
Question 4 True / False
Floating-point rounding errors indicate a poorly designed processor and can be eliminated by using more careful arithmetic circuit design.
TTrue
FFalse
Answer: False
Floating-point rounding errors are a mathematical inevitability of representing an infinite set of real numbers using a finite number of bits — not hardware bugs. Most real numbers, including simple decimals like 0.1, require infinitely many bits to represent exactly in binary. Any finite representation must round. Better hardware can reduce error (double precision uses 64 bits instead of 32), but cannot eliminate it without infinite storage. IEEE 754 specifies correct rounding rules so every operation produces the best possible approximation; the errors come from the limits of finite representation, not imprecision in the circuits.
Question 5 Short Answer
Explain why adding a very small floating-point number to a very large one might produce no change at all, using the concept of how representable values are spaced.
Think about your answer, then reveal below.
Model answer: Floating-point values are not evenly spaced across the number line — they are densely packed near zero and increasingly sparse at larger magnitudes. Between consecutive powers of 2, there are exactly 2²³ representable values (single precision), so the gap between adjacent representable numbers grows as magnitude increases. If the small number is smaller than the gap between the large number and its nearest representable neighbor, the result rounds back to the large number unchanged. For example, if the gap near 1.0 is about 1.2 × 10⁻⁷, adding 10⁻⁸ to 1.0 has no effect because 10⁻⁸ falls below the resolution of the representation at that magnitude.
This phenomenon — sometimes called absorption — has real consequences in numerical algorithms. A running sum of many small values accumulated into a large total can lose precision as each addition falls below the representable gap. Algorithms like Kahan compensated summation address this by tracking the accumulated rounding error in a separate variable. Understanding representable value spacing is essential for diagnosing and preventing precision loss in numerical computing.