Question: You are assigned the task of writing code for a function tsub_ok, with arguments x and y, that will return 1 if computing x-y does
You are assigned the task of writing code for a function tsub_ok, with arguments x and y, that will return 1 if computing x-y does not cause overflow. Having just written the code for Problem 2.30, you write the following:

For what values of x and y will this function give incorrect results? Writing a correct version of this function is left as an exercise (Problem 2.74).
Problem 2.30
Write a function with the following prototype:
![]()
This function should return 1 if arguments x and y can be added without causing overflow.
Problem 2.74
Write a function with the following prototype:
![]()
We can represent a bit pattern of length w = 4 with a single hex digit. For a two’scomplement
interpretation of these digits, fill in the following table to determine
the additive inverses of the digits shown:This function should return 1 if the computation x-y does not overflow.
/* Determine whether arguments can be subtracted without overflow */ /* WARNING: This code is buggy. */ int tsub_ok (int x, int y) { return tadd_ok (x, -y); }
Step by Step Solution
3.61 Rating (158 Votes )
There are 3 Steps involved in it
This function will give correct values except when y is TMin In this case we will have y als... View full answer
Get step-by-step solutions from verified subject matter experts
