Exemple #1
0
        public long ReadLong()
        {
            BitLong bits = new BitLong();

            if (BitConverter.IsLittleEndian)
            {
                bits.ByteOffset7 = Buffer[Position];
                bits.ByteOffset6 = Buffer[Position + 1];
                bits.ByteOffset5 = Buffer[Position + 2];
                bits.ByteOffset4 = Buffer[Position + 3];
                bits.ByteOffset3 = Buffer[Position + 4];
                bits.ByteOffset2 = Buffer[Position + 5];
                bits.ByteOffset1 = Buffer[Position + 6];
                bits.ByteOffset0 = Buffer[Position + 7];
            }
            else
            {
                bits.ByteOffset0 = Buffer[Position];
                bits.ByteOffset1 = Buffer[Position + 1];
                bits.ByteOffset2 = Buffer[Position + 2];
                bits.ByteOffset3 = Buffer[Position + 3];
                bits.ByteOffset4 = Buffer[Position + 4];
                bits.ByteOffset5 = Buffer[Position + 5];
                bits.ByteOffset6 = Buffer[Position + 6];
                bits.ByteOffset7 = Buffer[Position + 7];
            }

            Position += sizeof(long);
            return(bits.Value);;
        }
Exemple #2
0
        public void Write(long value)
        {
            BitLong bits = new BitLong(value);

            if (BitConverter.IsLittleEndian)
            {
                Buffer[Position]     = bits.ByteOffset7;
                Buffer[Position + 1] = bits.ByteOffset6;
                Buffer[Position + 2] = bits.ByteOffset5;
                Buffer[Position + 3] = bits.ByteOffset4;
                Buffer[Position + 4] = bits.ByteOffset3;
                Buffer[Position + 5] = bits.ByteOffset2;
                Buffer[Position + 6] = bits.ByteOffset1;
                Buffer[Position + 7] = bits.ByteOffset0;
            }
            else
            {
                Buffer[Position]     = bits.ByteOffset0;
                Buffer[Position + 1] = bits.ByteOffset1;
                Buffer[Position + 2] = bits.ByteOffset2;
                Buffer[Position + 3] = bits.ByteOffset3;
                Buffer[Position + 4] = bits.ByteOffset4;
                Buffer[Position + 5] = bits.ByteOffset5;
                Buffer[Position + 6] = bits.ByteOffset6;
                Buffer[Position + 7] = bits.ByteOffset7;
            }

            Position += sizeof(long);
        }