short数组转int数组
short []a={...};
int []b=new int[a.Length];
for(int i=0;i<a.Length;i++)
{
     b[i]=(int)a[i];
}同理short数组转float数组
short []a={...};
float []b=new float[a.Length];
for(int i=0;i<a.Length;i++)
{
     b[i]=(float)a[i];
}

解决方案 »

  1.   

    首先,必须知道short数组里高字节在前,还是低字节在前,知道了就可以自己计算了
    比如
    for(int i=0;i<short1.Length;i++)
    {
    int1[i]=short1[i*2]*65536+(ushort)short1[i*2+1];
    }
    转float也一样,先把short[2]拆成4个byte,然后用BitConvert.ToSingle()转
      

  2.   

    还有,如果你需要不断的转来转去的,最好一开始就定义成byte数组,而不是short数组,省得来回拆
      

  3.   

    int的转来转去:
    我应该是解决了,虽然还不懂意思。
    int x = 12;
    short high_x = (short)((x & 0xffff0000) >> 16);
    short low_x = (short)(x & 0xffff);
    int y = high_x * 65536 + (ushort)low_x;float怎么转呢?继续求助
      

  4.   

    float这样转:            //float f = 123.456f;
                //byte[] b = BitConverter.GetBytes(f);
                //float f1 = BitConverter.ToSingle(b, 0);话说,移位和与运算不明白的话,你就像3楼给的代码那样,用乘法算就好了,等你能明白了,再用那些高大上的写法
    不要逻辑还没搞明白,就纠结底层CPU几个运算周期的效率问题,那是根本毫无意义的行为
    这代码过一个月,你自己能看懂?
      

  5.   

    int型转short型:
    short1=int1/65536;
    short2=int1%65536;
    其实就是对65536做除法,商是高字,余数是低字
      

  6.   

    那么short转byte也应该能很好理解了
    其实就是对256做除法嘛
    用左移位右移位效率是很高,CPU内部其实乘法除法就是通过移位来实现的
    但是你不理解的话,还是用你能理解的方法编程比较好
      

  7.   

    用Buffer.BlockCopy来转换,前提是你要确定字节序是正确的:
    short[] s = { 1, 2 };
    int[] i = new int[1];
    float[] f = new float[1];
    Buffer.BlockCopy(s, 0, i, 0, 4);
    Buffer.BlockCopy(s, 0, f, 0, 4);
    Console.WriteLine("{0} {1}", i[0], f[0]);