C# byte数组转float

2020-02-1913:57:48 评论 2,756 views

源码:

byte[] bFxianOrg = new byte[4];
//本例演示用数据: 0xBD636DE0 = -0.055525
//小端模式将单浮点数 -0.055525 对应的十六进制 0xBD636DE0 存储到 byte 数组变量 bFxianOrg :
bFxianOrg[0] = 0xE0;
bFxianOrg[1] = 0x6D;
bFxianOrg[2] = 0x63;
bFxianOrg[3] = 0xBD;
//BitConverter.ToSingle(byte数组变量名, byte数组的起始索引值);
float fValue = BitConverter.ToSingle(bFxianOrg, 0);

效果:

file

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: