Converting float values from big endian to little endian

前端 未结 9 1850
清歌不尽
清歌不尽 2020-11-30 02:40

Is it possible to convert floats from big to little endian? I have a big endian value from a PowerPC platform that I am sendING via TCP to a Windows process (li

9条回答
  •  感情败类
    2020-11-30 03:03

    Here is a function can reverse byte order of any type.

    template 
    T bswap(T val) {
        T retVal;
        char *pVal = (char*) &val;
        char *pRetVal = (char*)&retVal;
        int size = sizeof(T);
        for(int i=0; i

提交回复
热议问题