public override float ReadSingle() { var buffer = ReadBytes(4); var floatUnion = new ExtendedBinary.FloatUnion(); if (IsBigEndian) { floatUnion.UInt = ( (uint)buffer[0] << 24 | (uint)buffer[1] << 16 | (uint)buffer[2] << 8 | buffer[3]); } else { floatUnion.UInt = ( (uint)buffer[3] << 24 | (uint)buffer[2] << 16 | (uint)buffer[1] << 8 | buffer[0]); } return(floatUnion.Float); }
public override void Write(float value) { var floatUnion = new ExtendedBinary.FloatUnion(value); if (IsBigEndian) { dataBuffer[0] = (byte)(floatUnion.UInt >> 24); dataBuffer[1] = (byte)(floatUnion.UInt >> 16); dataBuffer[2] = (byte)(floatUnion.UInt >> 8); dataBuffer[3] = (byte)(floatUnion.UInt); } else { dataBuffer[0] = (byte)(floatUnion.UInt); dataBuffer[1] = (byte)(floatUnion.UInt >> 8); dataBuffer[2] = (byte)(floatUnion.UInt >> 16); dataBuffer[3] = (byte)(floatUnion.UInt >> 24); } Write(dataBuffer, 0, 4); }