Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We are running programs where values of type int are 32 bits. They are represented in two's complement, and they are right-shifted arithmetically. Values of

We are running programs where values of type int are 32 bits. They are represented in two's complement, and they are right-shifted arithmetically. Values of type unsigned are also 32 bits.

We generate 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;

For each of the following C expressions, you are to indicate whether or not the expression always yields 1.

If it always yields 1, describe the underlying mathematical principles.

Otherwise, give an example of arguments 'that make it yield 0.

A. (x-y) B. ((x+y) << 4) + y-x == 17*y+15*x C. ~x+~y+1 == ~(x+y) D. (ux-uy) == -(unsigned)(y-x) E. ((x >> 2) << 2) <= 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

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

LO2 Explain the major laws governing employee compensation.

Answered: 1 week ago