Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started