Ejemplo n.º 1
0
        // Read floating-point values.
        public virtual float ReadSingle()
        {
            int value;

            FillBuffer(4);
            if (BitConverter.IsLittleEndian)
            {
                value = ((int)(smallBuffer[0])) |
                        (((int)(smallBuffer[1])) << 8) |
                        (((int)(smallBuffer[2])) << 16) |
                        (((int)(smallBuffer[3])) << 24);
            }
            else
            {
                value = ((int)(smallBuffer[3])) |
                        (((int)(smallBuffer[2])) << 8) |
                        (((int)(smallBuffer[1])) << 16) |
                        (((int)(smallBuffer[0])) << 24);
            }
            return(BitConverter.Int32BitsToFloat(value));
        }
Ejemplo n.º 2
0
        // Read floating-point values.
        private static float ReadSingle(Stream stream)
        {
            int value;

            byte[] buf = new byte [4];
            stream.Read(buf, 0, 4);
            if (BitConverter.IsLittleEndian)
            {
                value = ((int)(buf[0])) |
                        (((int)(buf[1])) << 8) |
                        (((int)(buf[2])) << 16) |
                        (((int)(buf[3])) << 24);
            }
            else
            {
                value = ((int)(buf[3])) |
                        (((int)(buf[2])) << 8) |
                        (((int)(buf[1])) << 16) |
                        (((int)(buf[0])) << 24);
            }
            return(BitConverter.Int32BitsToFloat(value));
        }