public CalcItem(byte[] data, int offset) { this.IsValid = false; if (data[offset] == 0xff) { return; } this.Gear = data[offset] & 0x03; //档位 int freqIndex = (data[offset] >> 4) & 0x0f; this.Freq = 0; if (freqIndex < FreqList.Length) { this.Freq = FreqList[freqIndex]; } float[] fd = new float[1]; ushort[] sd = new ushort[] { BitConverter.ToUInt16(data, offset + 1) }; HalfFloat.Halfp2Singles(fd, sd, 1); this.CoeffK = fd[0]; sd = new ushort[] { BitConverter.ToUInt16(data, offset + 3) }; HalfFloat.Halfp2Singles(fd, sd, 1); this.CoeffB = fd[0]; this.IsValid = true; }
private void button1_Click(object sender, EventArgs e) { float[] ff = new float[1]; HalfFloat.Halfp2Singles(ff, new ushort[] { (ushort)0x33cd }, 1); Console.WriteLine(); }