Exemple #1
0
        public override void Write(long value)
        {
            if (!IsLittleEndian)
            {
                value = ByteSwap.SwapBytes(value);
            }

            base.Write(value);
        }
Exemple #2
0
        public override unsafe void Write(float value)
        {
            if (!IsLittleEndian)
            {
                value = *(float *)ByteSwap.SwapBytes(*(uint *)&value);
            }

            base.Write(value);
        }
Exemple #3
0
        public override unsafe void Write(double value)
        {
            // BitConverter.DoubleToInt64Bits:
            // return *((long*)&value);
            //
            if (!IsLittleEndian)
            {
                value = BitConverter.Int64BitsToDouble(ByteSwap.SwapBytes(BitConverter.DoubleToInt64Bits(value)));
            }

            base.Write(value);
        }
Exemple #4
0
        public override ulong ReadUInt64()
        {
            var value = base.ReadUInt64();

            return(IsLittleEndian ? value : ByteSwap.SwapBytes(value));
        }
Exemple #5
0
        public override int ReadInt32()
        {
            var value = base.ReadInt32();

            return(IsLittleEndian ? value : ByteSwap.SwapBytes(value));
        }
Exemple #6
0
        public override ushort ReadUInt16()
        {
            var value = base.ReadUInt16();

            return(IsLittleEndian ? value : ByteSwap.SwapBytes(value));
        }