ALU 101 Overflow and Error Handling 2 — Questions and Answers
Question 1: What causes a divide-by-zero exception in an ALU?
- The dividend is larger than the divisor
- The divisor operand equals zero, making the quotient mathematically undefined (Correct answer)
- The dividend is negative
- The result exceeds 32 bits
Correct answer: The divisor operand equals zero, making the quotient mathematically undefined
Division by zero is undefined mathematically; the ALU detects a zero divisor and raises an exception rather than producing an infinite or garbage result.
Question 2: In IEEE 754 floating-point, what value does the FPU produce for a division by zero operation?
- Zero
- NaN (Not a Number)
- Positive or negative infinity (Correct answer)
- The maximum representable float
Correct answer: Positive or negative infinity
IEEE 754 defines that a finite non-zero number divided by zero yields ±infinity, with the sign determined by the operand signs.
Question 3: What is a NaN (Not a Number) result in floating-point ALU operations?
- Any negative float result
- A special bit pattern indicating an undefined or unrepresentable result such as 0/0 or sqrt(-1) (Correct answer)
- An integer overflow result
- A denormalized small number
Correct answer: A special bit pattern indicating an undefined or unrepresentable result such as 0/0 or sqrt(-1)
NaN is produced by operations with no valid numeric result, such as 0.0/0.0 or the square root of a negative number, and propagates through subsequent computations.
Question 4: What does 'silent NaN' vs 'signaling NaN' mean in IEEE 754?
- Silent NaN causes a trap; signaling NaN does not
- Signaling NaN raises a floating-point exception when used; quiet NaN propagates silently (Correct answer)
- They are identical
- Silent NaN only occurs in hardware, signaling NaN only in software
Correct answer: Signaling NaN raises a floating-point exception when used; quiet NaN propagates silently
A signaling NaN (sNaN) raises an invalid operation exception if used in a computation; a quiet NaN (qNaN) propagates through operations without raising exceptions.
Question 5: How does the ALU detect and flag an underflow condition in floating-point arithmetic?
- When the exponent exceeds its maximum value
- When the result is too small to be represented as a normalized number (Correct answer)
- When two negative numbers are added
- When the mantissa overflows
Correct answer: When the result is too small to be represented as a normalized number
Underflow occurs when the magnitude of the result is smaller than the smallest normalized floating-point number, causing precision loss or a flush to zero.
Question 6: What is 'double rounding' error in floating-point ALU computations?
- Rounding that occurs twice in a single multiplication
- Error introduced when an intermediate result is rounded to extended precision then rounded again to final precision (Correct answer)
- Rounding error in two consecutive additions
- Error from using two different rounding modes
Correct answer: Error introduced when an intermediate result is rounded to extended precision then rounded again to final precision
Double rounding happens when an intermediate result is first rounded to an 80-bit extended precision register and then rounded again to 64-bit double, potentially introducing more error than a single round to 64 bits would.
What causes a divide-by-zero exception in an ALU?