Beispiel #1
0
 //| <include file='doc\BinaryReader.uex' path='docs/doc[@for="BinaryReader.ReadSingle"]/*' />
 public virtual float ReadSingle()
 {
     FillBuffer(4);
     return(BitConverter.UInt32BitsToSingle(
                (uint)(m_buffer[0] | (m_buffer[1]) << 8 |
                       (m_buffer[2]) << 16 | m_buffer[3] << 24)));
 }
Beispiel #2
0
        private void TestRoundTripSingle(uint bits)
        {
            float d = BitConverter.UInt32BitsToSingle(bits);

            if (float.IsFinite(d))
            {
                string s = InvariantToStringSingle(d);
                CheckOneSingle(s, bits);
            }
        }
Beispiel #3
0
        public static void SingleToUInt32Bits()
        {
            float input  = 12345.63f;
            uint  result = BitConverter.SingleToUInt32Bits(input);

            Assert.Equal(1178658437U, result);
            float roundtripped = BitConverter.UInt32BitsToSingle(result);

            Assert.Equal(input, roundtripped);
        }
Beispiel #4
0
        public static Single ToFloat(this UInt32 bits)
        {
#if BITWISE_FLOAT_CONVERSION
            return(BitConverter.UInt32BitsToSingle(bits));
#else
            unsafe
            {
                return(*(Single *)&bits);
            }
#endif
        }
Beispiel #5
0
 private void CheckOneSingle(string s, uint expectedBits)
 {
     CheckOneSingle(s, BitConverter.UInt32BitsToSingle(expectedBits));
 }