Ejemplo n.º 1
0
        public void Write(int value)
        {
            BitInt bits = new BitInt(value);

            if (BitConverter.IsLittleEndian)
            {
                Buffer[Position]     = bits.ByteOffset3;
                Buffer[Position + 1] = bits.ByteOffset2;
                Buffer[Position + 2] = bits.ByteOffset1;
                Buffer[Position + 3] = bits.ByteOffset0;
            }
            else
            {
                Buffer[Position]     = bits.ByteOffset0;
                Buffer[Position + 1] = bits.ByteOffset1;
                Buffer[Position + 2] = bits.ByteOffset2;
                Buffer[Position + 3] = bits.ByteOffset3;
            }

            Position += sizeof(int);
        }
Ejemplo n.º 2
0
        public int ReadInt()
        {
            BitInt bits = new BitInt();

            if (BitConverter.IsLittleEndian)
            {
                bits.ByteOffset3 = Buffer[Position];
                bits.ByteOffset2 = Buffer[Position + 1];
                bits.ByteOffset1 = Buffer[Position + 2];
                bits.ByteOffset0 = Buffer[Position + 3];
            }
            else
            {
                bits.ByteOffset0 = Buffer[Position];
                bits.ByteOffset1 = Buffer[Position + 1];
                bits.ByteOffset2 = Buffer[Position + 2];
                bits.ByteOffset3 = Buffer[Position + 3];
            }

            Position += sizeof(int);
            return(bits.Value);
        }