Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

D) (10 Points) Consider running a C program that generates arbitrary values x and y, and convert them to unsigned values as follows: /* Create

D) (10 Points) Consider running a C program that generates arbitrary values x and y, and convert them to unsigned values as follows:

/* Create some arbitrary values */

int x = random();

int y = random();

/* Convert to unsigned */

unsigned ux = (unsigned) x;

unsigned uy = (unsigned) y;

Assume that:

- Values of type int are 32 bits.

- Values are represented in twos complement.

- Values are right shifted arithmetically.

- Values of type unsigned are also 32 bits

For each of the following C expressions, you are to indicate whether or not the expression always yields 1. If it always yields 1, explain why or describe the underlying mathematical principle. Otherwise, give an example of arguments that makes it yield 0.

1) (x < y) == (-x > -y)

2) ~x + ~y + 1 == ~(x + y)

3) (ux uy) == -(unsigned) (y x)

4) ((x >> 2) << 2) <= x

5) ((x + y) << 4) + y x == 17 * y + 15 * x

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

6. The cost of the training creates a need to show that it works.

Answered: 1 week ago