求这两个算法
Float.floatToRawIntBits(paramFloat)
Double.doubleToRawLongBits(paramDouble)这个是反的,
private float intBitsToFloat(int bits)
        {
            int s = ((bits >> 31) == 0) ? 1 : -1;
            int e = ((bits >> 23) & 0xff);
            int m = (e == 0) ?
              (bits & 0x7fffff) << 1 :
              (bits & 0x7fffff) | 0x800000;            return (float)(s * m * Math.Pow(2, e - 150));
        }        private double longBitsToDouble(long bits)
        {
            int s = ((bits >> 63) == 0) ? 1 : -1;
            int e = (int)((bits >> 52) & 0x7ffL);
            long m = (e == 0) ?
                            (bits & 0xfffffffffffffL) << 1 :
                            (bits & 0xfffffffffffffL) | 0x10000000000000L;            return (s * m * Math.Pow(2, e - 1075));
        }

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                float[] input = { 1277.995f, 219.7558f, 1004.7796f };
                uint[] convtoint = input.Select(x => ftol(x)).ToArray();
                foreach (var item in convtoint)
                {
                    Console.WriteLine(item);
                }
                Console.WriteLine("---------");
                var convback = convtoint.Select(x => ltof(x));
                foreach (var item in convback)
                {
                    Console.WriteLine(item);
                }
            }        private static float ltof(uint x)
            {
                byte[] b = BitConverter.GetBytes(x);
                return BitConverter.ToSingle(b, 0);
            }        static uint ftol(float f)
            {
                byte[] r = BitConverter.GetBytes(f);
                return (uint)(r[3] * 16777216 + r[2] * 65536 + r[1] * 256 + r[0]);
            }
        }
    }
    1151320023
    1130086780
    1148924389
    ---------
    1277.995
    219.7558
    1004.78
    Press any key to continue . . .
      

  2.   

    第二个函数这样就可以了:
    static uint ftol(float f)
    {
        byte[] r = BitConverter.GetBytes(f);
        return BitConverter.ToUInt32(r, 0);
    }