コード例 #1
0
        public void Write(uint source, int numberOfBits)
        {
            int newLength = bitLength + numberOfBits;

            ExpandBuffer(newLength);
            BitWriter.WriteUInt32(source, numberOfBits, data, bitLength);
            bitLength = newLength;
        }
コード例 #2
0
        //public void Write( sbyte source )
        //{
        //   unchecked
        //   {
        //      Write( (byte)source );
        //   }
        //}

        //public void Write( sbyte source, int numberOfBits )

        public void Write(ushort source)
        {
            int newLength = bitLength + 16;

            ExpandBuffer(newLength);
            BitWriter.WriteUInt32((uint)source, 16, data, bitLength);
            bitLength = newLength;
        }
コード例 #3
0
        public void Write(uint source)
        {
            int newLength = bitLength + 32;

            ExpandBuffer(newLength);

            if (bitLength % 8 == 0)
            {
                unsafe
                {
                    fixed(byte *numRef = &data[bitLength / 8])
                    {
                        *((uint *)numRef) = source;
                    }
                }
            }
            else
            {
                BitWriter.WriteUInt32(source, 32, data, bitLength);
            }

            bitLength = newLength;
        }
コード例 #4
0
        public void Write(int source, int numberOfBits)
        {
            int newLength = bitLength + numberOfBits;

            ExpandBuffer(newLength);

            if (numberOfBits != 32)
            {
                //make first bit sign
                int signBit = 1 << (numberOfBits - 1);
                if (source < 0)
                {
                    source = (-source - 1) | signBit;
                }
                else
                {
                    source &= (~signBit);
                }
            }

            BitWriter.WriteUInt32((uint)source, numberOfBits, data, bitLength);

            bitLength = newLength;
        }