You are assigned the task of writing code for a function tsub_ok, with arguments x and y,

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 not cause overflow. Having just written the code for Problem 2.30, you write the following:

/* Determine whether arguments can be subtracted without overflow */ /* WARNING: This code is buggy. */ int

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:

/* Determine whether arguments can be added without overflow */ int tadd_ok (int x, int y);

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:

/* Determine whether arguments can be subtracted without overflow */ int tsub_ok (int x, int y);

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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Computer Systems A Programmers Perspective

ISBN: 9781292101767

3rd Global Edition

Authors: Randal E. Bryant, David R. O'Hallaron

Question Posted: