’m working on Preliminary Exercise 8 and need some clarification regarding the problem requirements. Here’s the task description:
-
Input: A 5-bit binary number
x[4:0]
in 2’s complement form. -
Output: A 4-bit binary string
y[3:0]
representing the absolute value of the input.
Main Issue:
In 2’s complement representation with 4 bits, it is impossible to represent the absolute value of -16. This is because the range of a 4-bit 2’s complement number is -8 to +7
, and -16 exceeds this range.
The exercise specifies that the output is a 4-bit binary string, but if the input is -16 (e.g., 10000
in 5-bit 2’s complement), its absolute value would be 16
, which cannot be represented using just 4 bits.
Questions:
- Did I misunderstand the functionality of the exercise?
- Is the task asking for a workaround in such edge cases (e.g., truncating overflow values, flagging an error, or defining a special behavior for -16)?
- Or should the circuit assume that inputs are restricted to values within the representable range of the 4-bit output (
-8 to +7
in 2’s complement)?
I appreciate any help in clarifying this!