移位操作
程序员文章站
2022-07-02 17:28:27
1. u16 g_summ = 0; u8 buf[2] = {0x10, 0x05}; g_summ = (buf[1] << 8) | buf[0]; // g_summ = 0x0510 2. u16 g_summ = 0x0510; buf[0] = (u8 )g_summ; // buf[ ......
1.
u16 g_summ = 0;
u8 buf[2] = {0x10, 0x05};
g_summ = (buf[1] << 8) | buf[0]; // g_summ = 0x0510
2.
u16 g_summ = 0x0510;
buf[0] = (u8 )g_summ; // buf[0] = 0x10
buf[1] = (u8 )(g_summ >> 8); // buf[1] = 0x05
上一篇: 工厂模式讲解, 引入Spring IOC
下一篇: Django报错解决方法