Exemple #1
0
 public void Write(float value)
 {
     WriteImpl(Format.Float32);
     ExpendSizeIfNeed(4);
     FloatUnion.Write(value, m_Buf, m_Position);
     m_Position += 4;
 }
Exemple #2
0
        internal static void Write(float value, byte[] buf, int offset)
        {
            FloatUnion conv = new FloatUnion(value);

            if (BitConverter.IsLittleEndian)
            {
                buf[offset + 0] = conv.m_Byte3;
                buf[offset + 1] = conv.m_Byte2;
                buf[offset + 2] = conv.m_Byte1;
                buf[offset + 3] = conv.m_Byte0;
            }
            else
            {
                buf[offset + 0] = conv.m_Byte0;
                buf[offset + 1] = conv.m_Byte1;
                buf[offset + 2] = conv.m_Byte2;
                buf[offset + 3] = conv.m_Byte3;
            }
        }
Exemple #3
0
        internal static float Read(byte[] buf, int offset)
        {
            FloatUnion conv = default(FloatUnion);

            if (BitConverter.IsLittleEndian)
            {
                conv.m_Byte0 = buf[offset + 3];
                conv.m_Byte1 = buf[offset + 2];
                conv.m_Byte2 = buf[offset + 1];
                conv.m_Byte3 = buf[offset + 0];
            }
            else
            {
                conv.m_Byte0 = buf[offset + 0];
                conv.m_Byte1 = buf[offset + 1];
                conv.m_Byte2 = buf[offset + 2];
                conv.m_Byte3 = buf[offset + 3];
            }
            return(conv.m_Value);
        }
Exemple #4
0
 public float ReadFloat32()
 {
     m_Pos += 4;
     return(FloatUnion.Read(m_Buf, m_Pos - 4));
 }