Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

9. Consider the fowling C code. 12 Points int fun1(unsigned word){ return (int) ( ( word < < 24 ) >> 24); } int fun2(unsigned

9. Consider the fowling C code. 12 Points

int fun1(unsigned word){

return (int) ( ( word << 24 ) >> 24);

}

int fun2(unsigned word){

return ( (int) ( word << 24 ) >> 24);

}

Assume these are executed as a 32-bit program on a machine that uses twos-complement arithmetic. Assume also that right shift of signed values are performed arithmetically, while right shift of unsinged values are preformed logically.

Note: the difference between fun1 and fun2 is that fun1 shift the number first then cast into int, fun2 first cast then shift. Unsigned and int both has bit length equal to 32.

Fill in the following table showing the effect of these functions for several example arguments. Please use your result in hexadecimal form as the first example shows with blue color.

w fun1(w) fun2(w)

___________________________________________

0x00000076 0x00000076 0x00000076

0x00CDEFEF 0x____________ 0x_______________ (4 points)

0x1234569C 0x____________ 0x_______________ (4 points)

0x233333B8 0x____________ 0x_______________ (4 points)

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

b. Explain how you initially felt about the communication.

Answered: 1 week ago