本文介绍了如何添加一点半字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Hi 我想在半字节中添加一个比特,因为我想通过在每个数据块中添加一个额外的比特将8比特数据分段为2个4比特半字节,并且在接收端执行将接收数据5位的形式,之后将删除额外的位和Assemble 2半字节的HiI want to add a single bit in the nibble as i want to fragment 8 bits data into 2 4 bit nibble's by adding an extra bit to each of them and do on the reception side will receive data in the form of 5 bit, after that will remove the extra bit and Assemble 2 nibble's推荐答案 int N = //... bit numberint value = //... can be any integer type, signed or unsignedvalue |= 1 << N; // same as:value = value | (1 << N) 清除一下,使用按位AND和补码: To clear a bit, use bitwise AND with the complement:value &= ~(1 << N); 这就是全部。学习按位运算符: http://www.learncpp.com/cpp-tutorial/38-bitwise-operators [ ^ ]。 -SA 这篇关于如何添加一点半字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-26 21:44