位(bit)操作技巧 – 5

7

Q:如何对Byte做奇偶校验
A:可使用异或对所有位进行操作

如下偶校验

   A     #bit_nr_0
   X     #bit_nr_1
   X     #bit_nr_2
   X     #bit_nr_3
   X     #bit_nr_4
   X     #bit_nr_5
   X     #bit_nr_6
   X     #bit_nr_7
   =     #Parity

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.