예제 #1
0
        public override int SingleToInt32Bits(float value)
        {
            int fmant;
            int i;
            int t;
            int fconv = new Int32SingleUnion(value).AsInt32;

            if (fconv != 0)
            {
                fmant = (0x007fffff & fconv) | 0x00800000;
                t     = ((0x7f800000 & fconv) >> 23) - 126;
                while ((t & 0x3) != 0)
                {
                    ++t; fmant >>= 1;
                }
                fconv = (int)(0x80000000 & fconv) | (((t >> 2) + 64) << 24) | fmant;
            }
            fconv = (fconv << 24) | ((fconv >> 24) & 0xff) | ((fconv & 0xff00) << 8) | ((fconv & 0xff0000) >> 8);
            int to = fconv;

            return(to);
        }
예제 #2
0
 public int SingleToInt32Bits(float value)
 {
     Int32SingleUnion union = new Int32SingleUnion(value);
     return union.AsInt32;
 }
예제 #3
0
 public float Int32BitsToSingle(int value)
 {
     Int32SingleUnion union = new Int32SingleUnion(value);
     return union.AsSingle;
 }
예제 #4
0
        public int SingleToInt32Bits(float value)
        {
            Int32SingleUnion union = new Int32SingleUnion(value);

            return(union.AsInt32);
        }
예제 #5
0
        public float Int32BitsToSingle(int value)
        {
            Int32SingleUnion union = new Int32SingleUnion(value);

            return(union.AsSingle);
        }
예제 #6
0
        public static void WriteSingle(byte[] data, int startIndex, float value)
        {
            var union = new Int32SingleUnion(value);

            WriteInt32(data, startIndex, union.i);
        }
예제 #7
0
        public static float ReadSingle(byte[] data, int startIndex)
        {
            var union = new Int32SingleUnion(ReadInt32(data, startIndex));

            return(union.f);
        }