Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public float ReadSingle()
        {
            FloatInt fi = new FloatInt();

            fi.ivalue = (int)(_items[_ptr++] | _items[_ptr++] << 8 | _items[_ptr++] << 16 | _items[_ptr++] << 24);
            return(fi.fvalue);
        }
Esempio n. 3
0
        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)
            });
        }
Esempio n. 4
0
        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);
        }