Preliminary Exercise 8 edge case

image
’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:

  1. Did I misunderstand the functionality of the exercise?
  2. 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)?
  3. 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!

You can assume that no overflow occurs, i.e. you can assume that the input represents a number -15 \le p \le 15. In addition, note that the output is a binary string in standard (unsigned) binary representation.