C# float与UInt16互转

//float拆分成两个UInt16
public static UInt16 FloatToTwoUInt16(float f)
{
     byte[] bs = BitConvert.GetBytes();
     
     UInt16 low = BitConverter.ToUInt16(bs, 0);
     UInt16 high = BitConvert.ToUInt16(bs, 2);

     return new UInt16[]{low, high};
  }

//UInt16转float
public static float TwoUInt16ToFloat(UInt16 high, UInt16 low)
{
  Int32 sum = (high << 16)+(low & 0xFFFF);
  byte[] bs = BitConverter.GetBytes(sum);
  return BitConverter.ToSingle(bs, 0);
}
原文地址:https://www.cnblogs.com/144823836yj/p/10026013.html