Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想获得uint16_tC中的最低字节。
uint16_t
例子:
20544 = 0x5040 0x40 = 64
我试过了,(X & ((1<<2) - 1))。这对我不起作用。
(X & ((1<<2) - 1))
您使用字节(复数),但 auint16_t由两个字节组成,所以我假设您的意思是最低有效字节(单数)。如果是这样,这是获得它的一种方法:
uint8_t lsb = ((uint8_t)(((uint32_t)(val)) & 0xFF))