2.55, 2.56, and 2.57 are practice exercises. 2.58. Solution is not unique. int is_big_endian() { int a = 0xf0000000; char *b = (char*) &a; return *b != 0; } 2.61. A) !!x B) !!~x Assuming ints are 4 bytes: C) !!(x & 0xff000000) Without the assumption: C) !!(x & (0xff << (sizeof(int)-1)*8)) D) !!(~x & 0xff) Extract bit n. int testn(int a, unsigned int n) { return (a & (1 << n)) != 0; } void set(int* a, unsigned int n) { // This will not be compiled as / and %. unsigned int position = n / (8*sizeof(int)); unsigned int offset = n % (8*sizeof(int)); a[position] |= (1 << offset); } void reset(int *a, unsigned int n) { unsigned int position = n / (8*sizeof(int)); unsigned int offset = n % (8*sizeof(int)); a[position] &= ~(1 << offset); }