随笔分类 - CSAPP课后习题
摘要:/* Return 1 when any odd bit of x equals 1; 0 otherwise. Assume w = 32 */ #include <stdio.h> int any_odd_one(unsigned x) { unsigned mask = 0xAAAAAAAA;
阅读全文
摘要://csapp 2.63, 还原算数右移,逻辑右移 include unsigned srl(unsigned x, int k) { / Perform shift arithmetically / unsigned xsra = (int) x k; //begin this //此处由于转换成
阅读全文
摘要://csapp 2.62 include //算数右移返回1,否则返回0 int int_shifts_are_arithmetic() { //return !~( 1 1); unsigned int w = sizeof(int) (w 1)); } int main(void) { prin
阅读全文
摘要://csapp2.61 编写表达式,下列条件下产生1,否则0,假设x是int类型,不允许使用 ==,!= include typedef unsigned char byte_printer; //打印二进制数据 void show_bytes (byte_printer start, size_t
阅读全文
摘要://csapp 2.60 include include typedef unsigned char char_point; uint32_t replace_byte(uint32_t x, int i, unsigned char b) { if(i 3 || i < 0) { return 1
阅读全文
摘要://csapp 2.59 编写c语言表达式,它由X最低有效字节,和y剩余字节组成 include include int main(void) { int32_t x,y,z; x = 0x89ABCDEF; y = 0x76543210; z = 0x765432EF; printf(" z==r
阅读全文
摘要://csapp 2.58 include include include typedef unsigned char char_point; / 判断机器类型,大端机返回0, 小端机返回1,其他返回 1 author : date : 2020 5 7 20:54:03 / int is_littl
阅读全文