Tag: 奇偶校验

如何计算纵向冗余校验(LRC)?

我试过维基百科的例子: http : //en.wikipedia.org/wiki/Longitudinal_redundancy_check 这是lrc(C#)的代码: /// /// Longitudinal Redundancy Check (LRC) calculator for a byte array. /// ex) DATA (hex 6 bytes): 02 30 30 31 23 03 /// LRC (hex 1 byte ): EC /// public static byte calculateLRC(byte[] bytes) { byte LRC = 0x00; for (int i = 0; i < bytes.Length; i++) […]

如何在7位二进制数上添加偶校验位

我继续上一个问题。 我正在制作ac#程序,用户输入一个7位二进制数,计算机打印出数字右侧偶校验位的数字。 我在挣扎。 我有一个代码,但它说BitArray是一个命名空间,但用作一个类型。 另外,有没有办法可以改进代码并使其更简单? namespace BitArray { class Program { static void Main(string[] args) { Console.WriteLine(“Please enter a 7-bit binary number:”); int a = Convert.ToInt32(Console.ReadLine()); byte[] numberAsByte = new byte[] { (byte)a }; BitArray bits = new BitArray(numberAsByte); int count = 0; for (int i = 0; i < 8; i++) { if (bits[i]) […]