Converting float values from big endian to little endian

前端 未结 9 1848
清歌不尽
清歌不尽 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:10

    This value is a float, but when I "memcpy" the value into a win32 float type and then call _byteswap_ulong on that value, I always get 0.0000?

    This should work. Can you post the code you have?

    However, if you care for performance (perhaps you do not, in that case you can ignore the rest), it should be possible to avoid memcpy, either by directly loading it into the target location and swapping the bytes there, or using a swap which does the swapping while copying.

提交回复
热议问题