public static float ReadSingle(byte[] packet, ref int position) { FloatInt fi = new FloatInt(); fi.ivalue = (int)(packet[position++] | packet[position++] << 8 | packet[position++] << 16 | packet[position++] << 24); return(fi.fvalue); }
public float ReadSingle() { FloatInt fi = new FloatInt(); fi.ivalue = (int)(_items[_ptr++] | _items[_ptr++] << 8 | _items[_ptr++] << 16 | _items[_ptr++] << 24); return(fi.fvalue); }
public static byte[] GetBytes(this float value) { FloatInt fi = new FloatInt(); fi.fvalue = value; return(new byte[] { (byte)fi.ivalue, (byte)(fi.ivalue >> 8), (byte)(fi.ivalue >> 16), (byte)(fi.ivalue >> 24) }); }
public void Write(float value) { if (_ptr + 4 >= _bufferSize) { Resize(4); } FloatInt fi = new FloatInt(); fi.fvalue = value; int val = fi.ivalue; _items[_ptr++] = (byte)val; _items[_ptr++] = (byte)(val >> 8); _items[_ptr++] = (byte)(val >> 16); _items[_ptr++] = (byte)(val >> 24); }