代碼給你 拿走吧
//第一種方法:
short D0 = 0;
short D1 = 16320;
byte[] L = System.BitConverter.GetBytes(D0);
byte[] H = System.BitConverter.GetBytes(D1);
byte[] f = new byte[H.Length + L.Length];
Buffer.BlockCopy(L, 0, f, 0, L.Length);
Buffer.BlockCopy(H, 0, f, L.Length, H.Length);
float FF = BitConverter.ToSingle(f, 0);
textBox1.Text = "結(jié)果應該是:" + FF.ToString();
//第二種方法:
int HH=0;
short D0 = 0;
short D1 = 16320;
HH |= (D1 & 0x0000ffff);
HH = (HH << 16) | (D0 & 0x0000ffff);
byte[] intBuff = BitConverter.GetBytes (HH);
float FF = BitConverter.ToSingle(intBuff, 0);
textBox1.Text = "結(jié)果應該是:" + FF.ToString();