Please briefly answer each of the following short-response questions. A. Suppose
ID: 3725870 • Letter: P
Question
Please briefly answer each of the following short-response questions. A. Suppose that we are using an n-bit signed representation. What is the smallest and largest representable integer? B. Hardware implementations of arithmetic operations typically detect overflows. An alternate ISA design choice might be to port this responsibility to the software. If the software is instead responsible for detecting integer overflow for arithmetic operations, how might one determine if an addition operation has overflowed? Develop equations that can be used for computing the sum term and carry term for each digit when adding two signed n-bit numbers. How can one detect overflow using these equations? Develop equations that can be used for computing the difference term and borrow term when subtracting two signed n-bit numbers. Hint: Keep in mind the 2's complement signed representation as well as what subtraction really is. C. D.Explanation / Answer
A
In n-bit signed representation, the smallest and largest reprentable integers are - 2n - 1 and + (2n - 1 - 1) repectively.
Example
Suppose a signed integer is 16 bits.The largest negative number that can be represented is -215 which is -32768.
The largest positive number that can be represented is + 215 -1 which is +32768.
B
Integer operations will overflow if the resulting value cannot be represented by the underlying representation of the integer.
We can check for overflow during addition operation in program code. Heres an example of C code
n+1 bits are needed for detecting overflows if an n-bit number representation is employed.
For example, in 16-bit arithmetic, 17 bits are required to detect or compensate for overflow.
This can be implemented in addition (subtraction) by letting a carry (borrow) occur into (from) the sign bit.