Esempio n. 1
0
        public static double ReadDouble(byte[] packet, ref int position)
        {
            DoubleLong dl = new DoubleLong();

            dl.lvalue = (packet[position++] | (long)packet[position++] << 8
                         | (long)packet[position++] << 16 | (long)packet[position++] << 24
                         | (long)packet[position++] << 32 | (long)packet[position++] << 40
                         | (long)packet[position++] << 48 | (long)packet[position++] << 56);
            return(dl.dvalue);
        }
Esempio n. 2
0
        public double ReadDouble()
        {
            DoubleLong dl = new DoubleLong();

            dl.lvalue = (_items[_ptr++] | (long)_items[_ptr++] << 8
                         | (long)_items[_ptr++] << 16 | (long)_items[_ptr++] << 24
                         | (long)_items[_ptr++] << 32 | (long)_items[_ptr++] << 40
                         | (long)_items[_ptr++] << 48 | (long)_items[_ptr++] << 56);
            return(dl.dvalue);
        }
Esempio n. 3
0
        public static byte[] GetBytes(this double value)
        {
            DoubleLong dl = new DoubleLong(); dl.dvalue = value;

            return(new byte[]
            {
                (byte)dl.lvalue, (byte)(dl.lvalue >> 8), (byte)(dl.lvalue >> 16), (byte)(dl.lvalue >> 24),
                (byte)(dl.lvalue >> 32), (byte)(dl.lvalue >> 40), (byte)(dl.lvalue >> 48), (byte)(dl.lvalue >> 56)
            });
        }
Esempio n. 4
0
        public void Write(double value)
        {
            if (_ptr + 8 >= _bufferSize)
            {
                Resize(8);
            }
            DoubleLong dl  = new DoubleLong(); dl.dvalue = value;
            long       val = dl.lvalue;

            _items[_ptr++] = (byte)val;
            _items[_ptr++] = (byte)(val >> 8);
            _items[_ptr++] = (byte)(val >> 16);
            _items[_ptr++] = (byte)(val >> 24);
            _items[_ptr++] = (byte)(val >> 32);
            _items[_ptr++] = (byte)(val >> 40);
            _items[_ptr++] = (byte)(val >> 48);
            _items[_ptr++] = (byte)(val >> 56);
        }