Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

int prob 2 5 9 ( int x , int y ) { return ( y & ~ 0 xFF ) | ( x &

int prob259(int x, int y){
return (y & ~0xFF)|(x & 0xFF);
}
unsigned replace_byte(unsigned x, int i, unsigned char b){
unsigned mask =0xFF <<(i *8);
return (x & ~mask)|(b <<(i *8));
}
int prob261A(int x){
return (x & 0xFF)==0xFF;
}
int prob261B(int x){
return (x & 0xFF000000)==0;
}
int prob261C(int x){
return (x & 0x00FFFFFF)==0x00FFFFFF;
}
int leftmost_one(unsigned x){
x |= x >>1;
x |= x >>2;
x |= x >>4;
x |= x >>8;
x |= x >>16;
return x & ~(x >>1);
}
int lower_one_mask(int n){
int mask =(1<<(n -1))-1;
return mask |(mask +1);
}
int main(){
// problem 2.59
printf("
Problem 2.59:
");
int x =0x89ABCDEF;
int y =0x76543210;
printf("0x%X
", prob259(x, y));
// problem 2.60
printf("
Problem 2.60:
");
printf("0x%X
", replace_byte(0x12345678,2,0xAB));
printf("0x%X
", replace_byte(0x12345678,0,0xAB));
// problem 2.61
printf("
Problem 2.61:
");
printf("%d
", prob261A(0x8)); // returns 1
printf("%d
", prob261B(-1)); // returns 0
printf("%d
", prob261C(0x100)); // returns 0
// problem 2.66

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

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago